Merge pull request #380 from expsa/purchase_req_chgs

Purchase req chgs
This commit is contained in:
eslam 2024-07-24 13:18:40 +03:00 committed by GitHub
commit f513b2cb34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 18 deletions

View File

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

View File

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