Merge pull request #1454 from expsa/pla-1514851-fix-budget-line-first
fix issue with selecting first line of budget
This commit is contained in:
commit
c477eb2671
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.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
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,32 @@ 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 len(budget_post.ids) > 1:
|
||||
raise ValidationError(
|
||||
_("The Expense account %s is assigned to more than one budget position %s")%(account_id.name,[x.name for x in budget_post]))
|
||||
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 +676,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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue