Browse Source

Mar 27 [UPDT] : Updated 'base_accounting_kit'

pull/278/merge
AjmalCybro 1 year ago
parent
commit
aa401f349c
  1. 24
      base_accounting_kit/models/account_move.py

24
base_accounting_kit/models/account_move.py

@ -65,8 +65,8 @@ class AccountMove(models.Model):
return res return res
def action_post(self): def action_post(self):
print(self.line_ids, "line")
result = super(AccountMove, self).action_post() result = super(AccountMove, self).action_post()
for inv in self: for inv in self:
context = dict(self.env.context) context = dict(self.env.context)
# Within the context of an invoice, # Within the context of an invoice,
@ -106,8 +106,8 @@ class AccountInvoiceLine(models.Model):
raise UserError(_( raise UserError(_(
'The number of depreciations or the period length of your asset category cannot be null.')) 'The number of depreciations or the period length of your asset category cannot be null.'))
months = cat.method_number * cat.method_period months = cat.method_number * cat.method_period
if record.move_id in ['out_invoice', 'out_refund']: if record.move_id.move_type in ['out_invoice', 'out_refund']:
record.asset_mrr = record.price_subtotal_signed / months record.asset_mrr = record.price_subtotal / months
if record.move_id.invoice_date: if record.move_id.invoice_date:
start_date = datetime.strptime( start_date = datetime.strptime(
str(record.move_id.invoice_date), DF).replace(day=1) str(record.move_id.invoice_date), DF).replace(day=1)
@ -258,11 +258,13 @@ class AccountInvoiceLine(models.Model):
tables, where_clause, where_clause_params = query.get_sql() tables, where_clause, where_clause_params = query.get_sql()
return tables, where_clause, where_clause_params return tables, where_clause, where_clause_params
@api.model @api.model_create_multi
def create(self, vals): def create(self, vals_list):
if vals.get('product_id'): for vals in vals_list:
product = self.env['product.product'].browse(vals['product_id']) product_id = vals.get('product_id')
template = self.env['product.template'].search( if product_id:
[('id', '=', product.product_tmpl_id.id)]) product = self.env['product.product'].browse(product_id)
vals['asset_category_id'] = template.asset_category_id.id template = product.product_tmpl_id
return super().create(vals) vals['asset_category_id'] = template.asset_category_id.id if (
template.asset_category_id) else False
return super().create(vals_list)

Loading…
Cancel
Save