update track after approve invoice (payable)
parent
5a04479129
commit
820ec298e7
|
@ -48,5 +48,31 @@ class AccountInvoice(Model):
|
||||||
"number": _get_number,
|
"number": _get_number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# override this function to push tracking
|
||||||
|
def create_fixed_assets(self,ids,context={}):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
if obj.fixed_assets:
|
||||||
|
raise Exception("Fixed assets already created for invoice %s"%obj.number)
|
||||||
|
for line in obj.lines:
|
||||||
|
acc=line.account_id
|
||||||
|
if acc.type!="fixed_asset":
|
||||||
|
continue
|
||||||
|
ass_type=acc.fixed_asset_type_id
|
||||||
|
if not ass_type:
|
||||||
|
continue
|
||||||
|
vals={
|
||||||
|
"name": line.description,
|
||||||
|
"type_id": ass_type.id,
|
||||||
|
"date_purchase": obj.date,
|
||||||
|
"price_purchase": line.amount, # XXX: should be tax-ex
|
||||||
|
"fixed_asset_account_id": acc.id,
|
||||||
|
"dep_rate": ass_type.dep_rate,
|
||||||
|
"dep_method": ass_type.dep_method,
|
||||||
|
"accum_dep_account_id": ass_type.accum_dep_account_id.id,
|
||||||
|
"dep_exp_account_id": ass_type.dep_exp_account_id.id,
|
||||||
|
"invoice_id": obj.id,
|
||||||
|
'track_id': line.track_id.id,
|
||||||
|
}
|
||||||
|
get_model("account.fixed.asset").create(vals)
|
||||||
|
|
||||||
AccountInvoice.register()
|
AccountInvoice.register()
|
||||||
|
|
Loading…
Reference in New Issue