-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
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?
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.
Checked the format of description and changes are done accordingly, thanks for informing !!
Yes, we need to add 'stock' in the depends, as we are checking on hand quantity (available quantity ), if we do not write stock in depends then we can't check or see how many quantity of a product is available or not. because this field is provided by the stock module
'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.
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.
ok!!
'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.
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.
yes, warning would only show for the first sale order line. Improved the return and warning message.
</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.
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.
removed the blank line !!
@@ -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!
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.
changes are done accordingly, thanks for informing !!
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.
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.
done.
# 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.
!
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 added this code because I thought if the quantity is less than or equal to zero, it could cause a problem, like wrong stock numbers. But the task did not say anything about checking for negative quantities, so I was not sure if I should add it. That's why I commented it out. waiting for your confirmation if I should keep it or not.
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.
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.
updated accordingly.
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
.
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.
yes, I removed that.
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)
- 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
b103d52
to
96c3b20
Compare
This improvement extends the Point of Sale customer-facing screen by: - Displaying the customer's name (or Guest if not assigned) below the total/change section. - Showing the Amount / Guest if guest count is available and greater than zero. - Separating refunded order lines into a distinct Refund section below the regular items. JavaScript enhancements: - Patched PosOrder.getCustomerDisplayData() to include: - displayCustomerName - amountDividedPerGuest - refundedItems and activeItems XML template modifications: - Used XPath inheritance to insert new rows into the customer display. - Replaced the original OrderWidget to support line segregation. This update improves the clarity and transparency of the POS display for customers, especially in multi-guest and refund scenarios.
669a076
to
b5b780b
Compare
…orkflow - Added send to pick functionality in POS frontend to allow sending orders for picking - Created a new XML template to show the Send to Pick button on the POS product screen - Added a method check existing picking in pos order model to check if a picking exists for the order - Implemented create picking set shipping method to set the shipping date and create picking - Updated process saved order method to handle picking creation and shipping logic - Connected frontend and backend using RPC with order access token for identification This improves the POS workflow by linking order processing with the picking and delivery system
b5b780b
to
b4e3284
Compare
- Added a new field to set the maximum number of tickets one user can book for an event. - Updated the ticket booking popup to check this limit when users try to book. - Made sure the limit works in both normal and single ticket selection views. - Showed this new field in the event ticket form so event organizers can easily set it. - Helps avoid situations where one user books too many tickets.
…talog view - Clicking on a product image now opens a image preview. - Created a custom JavaScript class to handle image click events - Used file viewer to display the full image - Updated the kanban XML view to support the new class - Applied mobile-specific image styling using SCSS
- Added a new QWeb PDF report named Mo Delivery Note under stock picking model. - Report structure is inherited from the standard delivery slip stock report delivery document. - Modified the stock move table to exclude sub-lines of kit products (phantom BoM components). - Applied filtering logic to only show main products where product uom qty is set and bom line id is not part of a phantom BoM. - Customized report title using partner name and picking reference. - Ensured proper report binding and integration via ir actions report.
[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.