38 lines
1.2 KiB
Diff
38 lines
1.2 KiB
Diff
# HG changeset patch
|
|
# User Sergi Almacellas Abellana <sergi@koolpi.com>
|
|
Add company domain on analytic entries
|
|
|
|
issue5104
|
|
|
|
review17201002
|
|
|
|
Index: trytond/trytond/modules/analytic_purchase/purchase.py
|
|
===================================================================
|
|
|
|
--- a/trytond/trytond/modules/analytic_purchase/purchase.py
|
|
+++ b/trytond/trytond/modules/analytic_purchase/purchase.py
|
|
@@ -79,3 +79,22 @@
|
|
and self.origin.purchase.state in ['cancel', 'draft']):
|
|
return False
|
|
return required
|
|
+
|
|
+ @fields.depends('origin')
|
|
+ def on_change_with_company(self, name=None):
|
|
+ pool = Pool()
|
|
+ PurchaseLine = pool.get('purchase.line')
|
|
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
|
+ name)
|
|
+ if isinstance(self.origin, PurchaseLine):
|
|
+ if self.origin.purchase:
|
|
+ return self.origin.purchase.company.id
|
|
+ return company
|
|
+
|
|
+ @classmethod
|
|
+ def search_company(cls, name, clause):
|
|
+ domain = super(AnalyticAccountEntry, cls).search_company(name, clause)
|
|
+ return ['OR',
|
|
+ domain,
|
|
+ [('origin.purchase.company',) + tuple(clause[1:]) +
|
|
+ tuple(('purchase.line',))]]
|
|
|