Skip to content

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

Draft
wants to merge 9 commits into
base: 18.0
Choose a base branch
from

Conversation

agir-odoo
Copy link

@agir-odoo agir-odoo commented Apr 2, 2025

[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

  • 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.

Ensures better control over order confirmation based on stock approval.

@robodoo
Copy link

robodoo commented Apr 2, 2025

Pull request status dashboard

@agir-odoo agir-odoo force-pushed the 18.0-practice-task-agir branch 8 times, most recently from 9643f88 to 137fcbf Compare April 9, 2025 08:18
@agir-odoo agir-odoo force-pushed the 18.0-practice-task-agir branch 7 times, most recently from 0665818 to b103d52 Compare April 15, 2025 18:45
Copy link

@nihp-odoo nihp-odoo left a 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',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name?

Comment on lines +5 to +7
'description': """
Add kit-type products with configurable sub-products and conditional report visibility
""",

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'],

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,

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

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):

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.

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">

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)

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)

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.

Copy link

@nihp-odoo nihp-odoo left a 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!

Comment on lines +5 to +7
'description': """
Adding salesperson button in pos
""",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'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/**/*',

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,

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

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?

Comment on lines +11 to +12


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

selectedSalesPerson: null
});
useHotkey("enter", () => this.onEnter());
this.loadSalespeople();

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">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<td class="salesperson-line-email">
</td>
<td>
<t t-if="this.props.currentSelectedSalesperson?.id === salesperson?.id">

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'

Comment on lines +50 to +52
<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>

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() {

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?

Copy link

@nihp-odoo nihp-odoo left a 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...

Comment on lines 5 to 13
'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.
""",
Copy link

@nihp-odoo nihp-odoo Apr 17, 2025

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?

Copy link
Author

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,

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.

Copy link
Author

@agir-odoo agir-odoo Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!!

Comment on lines 19 to 25
'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}."
)
}

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.

Copy link
Author

@agir-odoo agir-odoo Apr 24, 2025

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>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Author

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">

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!

Copy link
Author

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 !!

Comment on lines 55 to 65
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."
)

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment on lines +42 to +55
# 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."
# )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

Copy link
Author

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.

Comment on lines 55 to 65
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."
)

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.

Copy link
Author

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:

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.

Copy link
Author

@agir-odoo agir-odoo Apr 27, 2025

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
@agir-odoo agir-odoo force-pushed the 18.0-practice-task-agir branch from b103d52 to 96c3b20 Compare April 24, 2025 05:59
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.
@agir-odoo agir-odoo force-pushed the 18.0-practice-task-agir branch 3 times, most recently from 669a076 to b5b780b Compare May 16, 2025 12:57
…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
@agir-odoo agir-odoo force-pushed the 18.0-practice-task-agir branch from b5b780b to b4e3284 Compare May 16, 2025 13:01
agir-odoo added 3 commits May 23, 2025 10:39
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants