fix issue with selecting first line of budget
This commit is contained in:
parent
8464b99f8c
commit
659321b7c6
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -617,6 +617,8 @@ class PurchaseOrderCustom(models.Model):
|
|||
raise ValidationError(_("No analytic account for the project"))
|
||||
elif self.purchase_cost == 'product_line':
|
||||
pass # No analytic account assigned yet, it will be assigned later
|
||||
else:
|
||||
raise ValidationError(_("No analytic account for the purchase"))
|
||||
|
||||
for order in self:
|
||||
for rec in order.order_line:
|
||||
|
|
@ -626,30 +628,29 @@ class PurchaseOrderCustom(models.Model):
|
|||
if not analytic_account:
|
||||
raise ValidationError(
|
||||
_("Please put cost center to the product line") + ': {}'.format(rec.product_id.name))
|
||||
|
||||
if not (
|
||||
rec.product_id.property_account_expense_id.id and rec.product_id.property_account_expense_id.id
|
||||
or rec.product_id.categ_id.property_account_expense_categ_id.id):
|
||||
account_id = rec.product_id.property_account_expense_id and rec.product_id.property_account_expense_id or rec.product_id.categ_id.property_account_expense_categ_id
|
||||
if not account_id:
|
||||
raise ValidationError(
|
||||
_("This product has no expense account") + ': {}'.format(rec.product_id.name))
|
||||
|
||||
budget_post = self.env['account.budget.post'].search([]).filtered(lambda x: account_id in x.account_ids)
|
||||
if analytic_account:
|
||||
budget_lines = self.env['crossovered.budget.lines'].search(
|
||||
[('analytic_account_id', '=', analytic_account.id),
|
||||
('general_budget_id','in',budget_post.ids),
|
||||
('crossovered_budget_id.state', '=', 'done'),
|
||||
('crossovered_budget_id.date_from', '<=', self.date_order),
|
||||
('crossovered_budget_id.date_to', '>=', self.date_order)])
|
||||
|
||||
self.budget_id = budget_lines.mapped('crossovered_budget_id').id
|
||||
if budget_lines:
|
||||
remain = abs(budget_lines[0].remain)
|
||||
remain = abs(budget_lines.remain)
|
||||
amount += rec.price_subtotal
|
||||
new_balance = remain - amount
|
||||
confirmation_lines.append((0, 0, {
|
||||
'amount': rec.price_subtotal,
|
||||
'analytic_account_id': analytic_account.id,
|
||||
'description': rec.product_id.name,
|
||||
'budget_line_id': budget_lines[0].id,
|
||||
'budget_line_id': budget_lines.id,
|
||||
'remain': remain,
|
||||
'new_balance': new_balance,
|
||||
'account_id': rec.product_id.property_account_expense_id.id
|
||||
|
|
@ -672,7 +673,7 @@ class PurchaseOrderCustom(models.Model):
|
|||
'lines_ids': confirmation_lines,
|
||||
'po_id': self.id
|
||||
}
|
||||
budget_id = self.env['budget.confirmation'].create(data)
|
||||
self.env['budget.confirmation'].create(data)
|
||||
self.write({'state': 'waiting'})
|
||||
|
||||
def budget_resend(self):
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue