Modify the move and product price.

Task #045017
This commit is contained in:
Juanjo Garcia 2022-04-08 09:48:01 +02:00
parent 94e1f01e92
commit fc89a5a8d8
1 changed files with 8 additions and 2 deletions

View File

@ -479,13 +479,15 @@ class Weighing(Workflow, ModelSQL, ModelView):
'agronomics.weighing-account.invoice.line')
RecomputeCostPrice = pool.get('product.recompute_cost_price',
type='wizard')
Move = pool.get('stock.move')
default_invoice_line_values = InvoiceLine.default_get(
InvoiceLine._fields.keys(), with_rec_name=False)
invoice_line = InvoiceLine(**default_invoice_line_values)
to_save = []
to_save_moves = []
to_recompute_products = []
for weighing in weighings:
cost_price = Decimal(0)
if weighing.beneficiaries:
@ -533,7 +535,11 @@ class Weighing(Workflow, ModelSQL, ModelView):
)
to_save.append(weighing_invoice)
weighing.inventory_move.unit_price = cost_price
weighing.inventory_move.unit_price_updated = True
weighing.product_created.cost_price = cost_price
to_save_moves.append(weighing.inventory_move)
to_recompute_products.append(weighing.product_created)
Product.save([weighing.product_created])
session_id, _, _ = RecomputeCostPrice.create()
@ -545,7 +551,7 @@ class Weighing(Workflow, ModelSQL, ModelView):
recompute_cost_price.transition_recompute()
WeighingInvoiceLine.save(to_save)
Move.save(to_save_moves)
@classmethod
@Workflow.transition('processing')