diff --git a/odex25_purchase/purchase_custom_stock/i18n/ar_001.po b/odex25_purchase/purchase_custom_stock/i18n/ar_001.po index f65d1d599..82be35adc 100644 --- a/odex25_purchase/purchase_custom_stock/i18n/ar_001.po +++ b/odex25_purchase/purchase_custom_stock/i18n/ar_001.po @@ -249,7 +249,7 @@ msgstr "المستودع" #. module: purchase_custom_stock #: model:ir.model.fields.selection,name:purchase_custom_stock.selection__purchase_request__state__warehouse msgid "Warehouses Department" -msgstr "ادارة المسودعات" +msgstr "المستودعات" #. module: purchase_custom_stock #: model:ir.model,name:purchase_custom_stock.model_purchase_request_picking_wizard diff --git a/odex25_purchase/purchase_requisition_custom/models/purchase_order.py b/odex25_purchase/purchase_requisition_custom/models/purchase_order.py index f344e79c9..8e0f5cc30 100644 --- a/odex25_purchase/purchase_requisition_custom/models/purchase_order.py +++ b/odex25_purchase/purchase_requisition_custom/models/purchase_order.py @@ -457,24 +457,35 @@ class PurchaseOrderCustom(models.Model): self.requisition_id.state = 'purchase_manager' def button_confirm(self): - res = super(PurchaseOrderCustom, self).button_confirm() - for line in self.order_line: - analytic_account = line.account_analytic_id - budget_lines = analytic_account.crossovered_budget_line.filtered( - lambda x: - x.crossovered_budget_id.state == 'done' and - fields.Date.from_string(x.date_from) <= fields.Date.from_string( - self.date_order) <= fields.Date.from_string(x.date_to)) - amount = budget_lines.purchase_remain - amount += line.price_subtotal - budget_lines.write({'purchase_remain': amount}) - budget_lines.write({'reserve': abs(line.price_subtotal - budget_lines.reserve)}) + # res = super(PurchaseOrderCustom, self).button_confirm() + for order in self: + if order.state not in ['draft']: + continue + order._add_supplier_to_product() + # Deal with double validation process + if order._approval_allowed(): + order.button_approve() + else: + order.write({'state': 'to approve'}) + if order.partner_id not in order.message_partner_ids: + order.message_subscribe([order.partner_id.id]) + for line in order.order_line: + analytic_account = line.account_analytic_id + budget_lines = analytic_account.crossovered_budget_line.filtered( + lambda x: + x.crossovered_budget_id.state == 'done' and + fields.Date.from_string(x.date_from) <= fields.Date.from_string( + order.date_order) <= fields.Date.from_string(x.date_to)) + amount = budget_lines.purchase_remain + amount += line.price_subtotal + budget_lines.write({'purchase_remain': amount}) + budget_lines.write({'reserve': abs(line.price_subtotal - budget_lines.reserve)}) - if self.requisition_id.id: - self.requisition_id.state = 'done' - if self.request_id: - self.request_id.write({'state': 'done'}) - return res + if order.requisition_id.id: + order.requisition_id.state = 'done' + if order.request_id: + order.request_id.write({'state': 'done'}) + return True def action_unsign(self):