-
Notifications
You must be signed in to change notification settings - Fork 1.9k
18.0 practice task agir #688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Conversation
9643f88
to
137fcbf
Compare
662b14a
to
bcdf892
Compare
Ensure that Sales Orders cannot be confirmed without Zero Stock Approval, restricting Sales Users from modifying the field while allowing only Sales Administrators to approve orders. --> Inherited Model - Inherited the main model sale order. - Added a new boolean field zero stock approval in the sale order model. - Overridden fields get() to make the field read-only for Sales Users (sales person) - Made action confirm() to restrict order confirmation unless zero stock approval is checked. - Implemented sale order views xml to display zero stock approval after payment term id. Access Rights - Sales Administrator - Can edit the field. - Sales User : Read-only access. - Created a boolean field 'zero_stock_approval' to allow admins to approve orders with low stock - Only Sales Manager can edit this field; others see it as readonly - If any product has demand > available stock and the user is not a manager, they must get admin approval - Blocked order confirmation if quantity is less than available and no approval is given - Skipped stock check for service and combo products (only checked consu {goods} type) - Added a warning message popup when admin gives approval for a product with low stock Ensures better control over order confirmation based on stock approval.
…n POS UI - Created a new module salesperson button in pos - Added salesperson id field in posorder model to track salesperson - Created a new button Select Salesperson in POS frontend - Implemented the button in controlbutton xml - Developed select salesperson button js as an OWL component - Patched ControlButtons to include the Salesperson button in POS - Registered assets properly in manifest py for POS UI - Debugged and tested visibility of the button in POS UI
…sub-product - Introduced 'Is Kit' field on product templates to define kit-type products - Added Many2many field to select sub-products for a kit - Added smart button 'Configure Kit' on sale order line, visible only for kit products - Created a wizard to select sub-product quantity and price per main product - Sub-products are auto-added as separate sale order lines under the main kit line - Sub-product lines are read-only & priced at 0 (cost included in main product) - Sub-products support storable/consumable product types for stock tracking - Main product's unit price remains unchanged; subtotal includes sub-product costs - Sub-product lines are auto-deleted if the main kit line is removed - Added 'Print in Report' checkbox on Sale Order to control sub-product visibility - Applied conditional display of sub-products in: - Sale Order PDF - Portal Order Preview - Invoice PDF (QWeb-safe logic using t-set variables)
aaa079f
to
0665818
Compare
- Added a new field in product form to set a second UoM - Backend constraint to prevent primary and secondary UoM being the same - Loaded second UoM info into POS - Added custom Add Quantity button in POS control panel(before customer button) - Clicking the button opens a popup to enter quantity in second UoM - POS converts the quantity based on UoM ratio - Added validations in popup: - Show error if quantity is zero or negative or empty input - Optimized validation with translatable error message - UI improvements with conditional visibility and consistent UX
0665818
to
b103d52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @agir-odoo
Some suggestion and changes on your new_product_type_kit
.
After adding kit once, if I am again click on 'configure kit' and remove one of the kit lines then price is updated but the it is still present in sale order line.. Check it out!
Thanks!
@@ -0,0 +1,22 @@ | |||
{ | |||
'name': 'Dev Zero Stock Blockage', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name?
'description': """ | ||
Add kit-type products with configurable sub-products and conditional report visibility | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check indentation in codebase!
Add kit-type products with configurable sub-products and conditional report visibility | ||
""", | ||
'author': 'Raghav Agiwal', | ||
'depends': ['sale_management', 'stock', 'product'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need stock here? Also only sale_management
will work fine.
'report/report_invoice_templates.xml', | ||
], | ||
'installable': True, | ||
'application': True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this module as an application!
|
||
print_in_report = fields.Boolean( | ||
string="Print in report?", | ||
default=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be False
by default. This is used if we are going other way.
} | ||
} | ||
|
||
def unlink(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is letting user delete sub products. Check functional flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be inside wizard folder.
<field name="product_id" readonly="1"/> | ||
</group> | ||
|
||
<group string="Sub Products"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use <sheet>
instead of <group>
here.
_name = 'kit.wizard' | ||
_description = 'Kit Wizard' | ||
|
||
product_id = fields.Many2one('product.product', string='Product', required=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we using this field?
order_id = self.env.context.get("active_id") | ||
sale_order_line_id = self.env.context.get("default_sale_order_line_id") | ||
order = self.env["sale.order"].browse(order_id) | ||
parent_line = order.order_line.filtered(lambda l: l.id == sale_order_line_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid such variable names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @agir-odoo
Some comments on your salesperson_button_in_pos
task.
Thanks!
'description': """ | ||
Adding salesperson button in pos | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'description': """ | |
Adding salesperson button in pos | |
""", | |
'description': """ | |
Adding salesperson button in pos | |
""", |
Check codebase for more examples.
], | ||
'assets': { | ||
'point_of_sale._assets_pos': [ | ||
'salesperson_button_in_pos/static/src/app/**/*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can directly work in static/src
no need to create separate folder inside.
], | ||
}, | ||
'installable': True, | ||
'application': True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to make this an application.
@@ -0,0 +1,3 @@ | |||
from . import pos_order | |||
from . import pos_session | |||
from . import hr_employee |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we making this hr_employee
file?
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedSalesPerson: null | ||
}); | ||
useHotkey("enter", () => this.onEnter()); | ||
this.loadSalespeople(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call this.getSalespersons()
directly from here.
@@ -0,0 +1,24 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<odoo> | |||
<record id="view_pos_order_form" model="ir.ui.view"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout coding guidelines for ID naming.
https://www.odoo.com/documentation/18.0/contributing/development/coding_guidelines.html#xml-ids-and-naming
<td class="salesperson-line-email"> | ||
</td> | ||
<td> | ||
<t t-if="this.props.currentSelectedSalesperson?.id === salesperson?.id"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works on the whole salesperson! If I again click on the selected salesperson it gets deselected. We should allow this when we only click in the 'cross'
<div t-if="state.query" class="search-more-button d-flex justify-content-center my-2"> | ||
<button class="btn btn-lg btn-primary" t-on-click="onEnter">Search more</button> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we adding this button, it just triggers the notification!
this.state = useState({ selectedSalesPerson: null }); | ||
} | ||
|
||
async selectSalesperson() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing same thing twice? Here and in salesperson_list
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @agir-odoo
Some comments on your dev_zero_stock_bloackage
task.
Thanks...
'description': """ | ||
This module stops Sales Orders from being confirmed if any product is out of stock, unless a Sales Manager gives approval. | ||
Sales users can see the Zero Stock Approval field but cannot edit it. | ||
It only checks stock for physical products, not services or combos. | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is not proper.. checkout codebase.
Also, do we need stock
in depends?
'views/sale_order_views.xml', | ||
], | ||
'installable': True, | ||
'application': True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to make it an application.
'warning': { | ||
'title': "Heads Up!", | ||
'message': ( | ||
f"Just a quick reminder..!! You are approving this order where product '{line.product_id.display_name}' " | ||
f"has demand {line.product_uom_qty} > available {line.product_id.qty_available}." | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are 2 sale_order_line where product_uom_qty is greater than qty_available? Warning will display only the first one it found.
</xpath> | ||
</field> | ||
</record> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,14 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<odoo> | |||
<record id="view_sale_order_form" model="ir.ui.view"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name ID according to the coding guideline!
raise UserError( | ||
f"Cannot confirm this Sale Order.\n" | ||
f"Product '{line.product_id.display_name}' has only {available_qty} in stock, " | ||
f"but {demand_qty} is requested.\n" | ||
f"Approval is required to proceed." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too! same issue as warning.
# if demand_qty <= 0: | ||
# raise UserError( | ||
# f"You cannot confirm this Sale Order.\n" | ||
# f"Product '{line.product_id.display_name}' has a quantity of {demand_qty}.\n" | ||
# f"Quantity must be greater than zero." | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!
raise UserError( | ||
f"Cannot confirm this Sale Order.\n" | ||
f"Product '{line.product_id.display_name}' has only {available_qty} in stock, " | ||
f"but {demand_qty} is requested.\n" | ||
f"Approval is required to proceed." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too! same issue as warning.
def _onchange_zero_stock_approval(self): | ||
if self.zero_stock_approval and self.env.user.has_group('sales_team.group_sale_manager'): | ||
for line in self.order_line: | ||
if line.product_id.type in ['consu', 'product'] and line.product_uom_qty > line.product_id.qty_available: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no product_type
called product
.
[ADD] dev_zero_stock_blockage: implemented zero stock approval task
Ensure that Sales Orders cannot be confirmed without Zero Stock Approval,
restricting Sales Users from modifying the field while allowing only
Sales Administrators to approve orders.
--> Inherited Model
(sales person)
zero stock approval is checked.
after payment term id.
Access Rights
Ensures better control over order confirmation based on stock approval.