From 820ec298e7d1c6e8ff43798f4656e9aaa0e2b631 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Tue, 4 Aug 2015 19:05:45 +0700 Subject: [PATCH] update track after approve invoice (payable) --- netforce_clinic/models/account_invoice.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py index 763a70e..77bb01a 100644 --- a/netforce_clinic/models/account_invoice.py +++ b/netforce_clinic/models/account_invoice.py @@ -48,5 +48,31 @@ class AccountInvoice(Model): "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()