Skip to content

Commit

Permalink
[FIX] purhcase_stock,mrp: added field rule_id on the PO line and MO t…
Browse files Browse the repository at this point in the history
…o propagate date changes.

- When we change date of purchase order it should consider day difference of propagate date of the rule.

Task ID : 1913401
  • Loading branch information
hsh-odoo committed Feb 22, 2019
1 parent 1bbc689 commit 2a6e979
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions addons/mrp/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def _get_default_location_dest_id(self):
propagate = fields.Boolean(
'Propagate cancel and split',
help='If checked, when the previous move of the move (which was generated by a next procurement) is cancelled or split, the move generated by this move will too')
rule_id = fields.Many2one('stock.rule', string="Rule")
scrap_ids = fields.One2many('stock.scrap', 'production_id', 'Scraps')
scrap_count = fields.Integer(compute='_compute_scrap_move_count', string='Scrap Move')
priority = fields.Selection([('0', 'Not urgent'), ('1', 'Normal'), ('2', 'Urgent'), ('3', 'Very Urgent')], 'Priority',
Expand Down Expand Up @@ -497,6 +498,7 @@ def _generate_finished_moves(self):
'origin': self.name,
'group_id': self.procurement_group_id.id,
'propagate': self.propagate,
'rule_id': self.rule_id.id,
'move_dest_ids': [(4, x.id) for x in self.move_dest_ids],
})
return move
Expand Down
1 change: 1 addition & 0 deletions addons/mrp/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, na
'date_planned_finished': values['date_planned'],
'procurement_group_id': False,
'propagate': self.propagate,
'rule_id': self.id,
'orderpoint_id': values.get('orderpoint_id', False) and values.get('orderpoint_id').id,
'picking_type_id': self.picking_type_id.id or values['warehouse_id'].manu_type_id.id,
'company_id': company_id.id,
Expand Down
2 changes: 2 additions & 0 deletions addons/purchase_stock/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class PurchaseOrderLine(models.Model):
move_ids = fields.One2many('stock.move', 'purchase_line_id', string='Reservation', readonly=True, ondelete='set null', copy=False)
orderpoint_id = fields.Many2one('stock.warehouse.orderpoint', 'Orderpoint')
move_dest_ids = fields.One2many('stock.move', 'created_purchase_line_id', 'Downstream Moves')
rule_id = fields.Many2one('stock.rule', string="Rule")

@api.multi
def _compute_qty_received_method(self):
Expand Down Expand Up @@ -354,6 +355,7 @@ def _prepare_stock_moves(self, picking):
'picking_type_id': self.order_id.picking_type_id.id,
'group_id': self.order_id.group_id.id,
'origin': self.order_id.name,
'rule_id': self.rule_id.id,
'description_picking': self.product_id._get_description(self.order_id.picking_type_id),
'route_ids': self.order_id.picking_type_id.warehouse_id and [(6, 0, [x.id for x in self.order_id.picking_type_id.warehouse_id.route_ids])] or [],
'warehouse_id': self.order_id.picking_type_id.warehouse_id.id,
Expand Down
6 changes: 4 additions & 2 deletions addons/purchase_stock/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def _run_buy(self, procurements):
partner = supplier.name
# we put `supplier_info` in values for extensibility purposes
procurement.values['supplier'] = supplier
procurement.values['rule'] = rule

domain = rule._make_po_get_domain(procurement.company_id, procurement.values, partner)
procurements_by_po_domain[domain].append((procurement, rule))
Expand Down Expand Up @@ -115,11 +116,11 @@ def _run_buy(self, procurements):

@api.model
def _get_procurements_to_merge_groupby(self, procurement):
return procurement.product_id, procurement.product_uom
return procurement.product_id, procurement.product_uom, procurement.values.get('rule').id

@api.model
def _get_procurements_to_merge_sorted(self, procurement):
return procurement.product_id.id, procurement.product_uom.id
return procurement.product_id.id, procurement.product_uom.id, procurement.values.get('rule').id

@api.model
def _get_procurements_to_merge(self, procurements):
Expand Down Expand Up @@ -230,6 +231,7 @@ def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, com
'product_id': product_id.id,
'product_uom': product_id.uom_po_id.id,
'price_unit': price_unit,
'rule_id': values.get('rule', False) and values.get('rule').id,
'date_planned': date_planned,
'orderpoint_id': values.get('orderpoint_id', False) and values.get('orderpoint_id').id,
'taxes_id': [(6, 0, taxes_id.ids)],
Expand Down

0 comments on commit 2a6e979

Please sign in to comment.