[FIX] purchase(_stock): make orderpoint qtys depend on POs

Before this commit, `stock.warehouse.orderpoint` `_compute_qty` didn't
depend on `purchase.order.line` (POL). This means when a relevant POL
was edited/cancelled, then the `qty_forecast` wouldn't correctly update.

To reproduce:
- Create a product w/ a vendor and buy route active,
- Go to replenishment report, create a reordering rule, and hit
  order for product (RFQ should be created)
- Cancel the RFQ and go back to replenishment report

The product should reappear in the list view, but does not because it's
`qty_forecast` has not updated and therefore has not updated
corresponding `qty_to_order` value.

Note string rename of `purchase_line_warn` 'Purchase Order Line' =>
'Purchase Order Line Warning' is due to repeat label use issue. It is
better to rename the poorly labeled `purchase_line_warn` than to give a
hacky label for new One2many field.

Task: 2285912
Manual forward port of: odoo/odoo#56580 due to migration test error

closes odoo/odoo#56625

Closes: odoo/odoo#56625
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Tiffany Chang (tic)
2020-08-27 07:22:38 +00:00
parent 9f609565a2
commit 1d67f0583e
3 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ class ProductTemplate(models.Model):
('receive', 'On received quantities'),
], string="Control Policy", help="On ordered quantities: Control bills based on ordered quantities.\n"
"On received quantities: Control bills based on received quantities.", default="receive")
purchase_line_warn = fields.Selection(WARNING_MESSAGE, 'Purchase Order Line', help=WARNING_HELP, required=True, default="no-message")
purchase_line_warn = fields.Selection(WARNING_MESSAGE, 'Purchase Order Line Warning', help=WARNING_HELP, required=True, default="no-message")
purchase_line_warn_msg = fields.Text('Message for Purchase Order Line')
def _compute_purchased_product_qty(self):
+2
View File
@@ -23,6 +23,8 @@ class ProductProduct(models.Model):
_name = 'product.product'
_inherit = 'product.product'
purchase_order_line_ids = fields.One2many('purchase.order.line', 'product_id', help='Technical: used to compute quantities.')
def _get_quantity_in_progress(self, location_ids=False, warehouse_ids=False):
if not location_ids:
location_ids = []
+5
View File
@@ -183,6 +183,11 @@ class Orderpoint(models.Model):
'product.supplierinfo', string='Vendor', check_company=True,
domain="['|', ('product_id', '=', product_id), '&', ('product_id', '=', False), ('product_tmpl_id', '=', product_tmpl_id)]")
@api.depends('product_id.purchase_order_line_ids', 'product_id.purchase_order_line_ids.state')
def _compute_qty(self):
""" Extend to add more depends values """
return super()._compute_qty()
@api.depends('route_id')
def _compute_show_suppplier(self):
buy_route = []