account_analytic_distribution_model.py 1.2 KB

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from odoo import fields, models
  3. class AccountAnalyticDistributionModel(models.Model):
  4. _inherit = 'account.analytic.distribution.model'
  5. account_prefix = fields.Char(
  6. string='Accounts Prefix',
  7. help="Prefix that defines which accounts from the financial accounting this model should apply on.",
  8. )
  9. product_id = fields.Many2one(
  10. 'product.product',
  11. string='Product',
  12. ondelete='cascade',
  13. help="Select a product for which the analytic distribution will be used (e.g. create new customer invoice or Sales order if we select this product, it will automatically take this as an analytic account)",
  14. )
  15. product_categ_id = fields.Many2one(
  16. 'product.category',
  17. string='Product Category',
  18. ondelete='cascade',
  19. help="Select a product category which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this product, it will automatically take this as an analytic account)",
  20. )
  21. def _create_domain(self, fname, value):
  22. if not fname == 'account_prefix':
  23. return super()._create_domain(fname, value)