models.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # -*- coding: utf-8 -*-
  2. ###################################################################################
  3. #
  4. # Odoo, Open Source Management Solution
  5. # Copyright (C) 2014-TODAY Prime Consulting, Cape Verde (<http://www.prime.cv>).
  6. #
  7. ###################################################################################
  8. from odoo import models, fields, api
  9. class ResPartner(models.Model):
  10. _inherit = "res.partner"
  11. @api.depends('custom_sales_id')
  12. def set_custom_sales(self):
  13. for partner in self:
  14. if partner.custom_sales_id:
  15. partner.custom_sales = True
  16. else:
  17. partner.custom_sales = False
  18. region_id = fields.Many2one('res.partner.region', 'Region')
  19. division_id = fields.Many2one('res.partner.division', 'Division')
  20. segment_id = fields.Many2one('res.segment', 'Segment', domain=[('type','=','partner')])
  21. custom_sales = fields.Boolean('Custom Sales Partner?', compute="set_custom_sales", store=True)
  22. custom_sales_id = fields.Char('Custom Identifier')
  23. class ResPartnerRegion(models.Model):
  24. _name = "res.partner.region"
  25. _description = "Partner Region"
  26. name = fields.Char("Region Name", required=True, translate=True)
  27. class ResPartnerDivision(models.Model):
  28. _name = "res.partner.division"
  29. _description = "Partner Division"
  30. name = fields.Char("Division Name", required=True, translate=True)
  31. class ResSegment(models.Model):
  32. _name = "res.segment"
  33. _description = "Segment"
  34. type = fields.Selection([('partner', 'Partner'), ('product', 'Product')], 'Segment Type', required=True)
  35. name = fields.Char("Segment Name", required=True, translate=True)
  36. class ProductTemplate(models.Model):
  37. _inherit = "product.template"
  38. @api.depends('custom_sales_id')
  39. def set_custom_sales(self):
  40. for product in self:
  41. if product.custom_sales_id:
  42. product.custom_sales = True
  43. else:
  44. product.custom_sales = False
  45. segment_id = fields.Many2one('res.segment', 'Segment', domain=[('type','=','product')])
  46. site = fields.Char('Site')
  47. platform = fields.Char('Platform')
  48. custom_sales = fields.Boolean('Custom Sales Product?', compute="set_custom_sales", store=True)
  49. custom_sales_id = fields.Char('Custom Identifier')
  50. class ProductProduct(models.Model):
  51. _inherit = "product.product"
  52. @api.depends('custom_sales_id')
  53. def set_custom_sales(self):
  54. for product in self:
  55. if product.custom_sales_id:
  56. product.custom_sales = True
  57. else:
  58. product.custom_sales = False
  59. segment_id = fields.Many2one('res.segment', 'Segment', domain=[('type','=','product')])
  60. site = fields.Char('Site')
  61. platform = fields.Char('Platform')
  62. custom_sales = fields.Boolean('Custom Sales Product?', compute="set_custom_sales", store=True)
  63. custom_sales_id = fields.Char('Custom Identifier')
  64. class CustomSaleOrder(models.Model):
  65. _name = "custom.sale.order"
  66. _description = "Custom Sales Order"
  67. _inherit = ['mail.thread', 'ir.needaction_mixin']
  68. custom_sales_id = fields.Char('Custom Identifier', required=True)
  69. date = fields.Date('Date')
  70. year = fields.Char('Year')
  71. month = fields.Char('Month')
  72. planning_scenario = fields.Char('Planning Scenario')
  73. partner_division_id = fields.Many2one('res.partner.division', 'Division')
  74. partner_id = fields.Many2one('res.partner', 'Customer', domain=[('custom_sales','=',True)])
  75. sale_type = fields.Char('Type of Sales')
  76. pipeline_category = fields.Char('Pipeline Category')
  77. product_id = fields.Many2one('product.product', 'Product')
  78. quantity = fields.Float('Quantity')
  79. quantity_actuals = fields.Float('Quantity Actuals')
  80. quantity_total_pipeline = fields.Float('Quantity total pipeline')
  81. amount_forecast = fields.Float('Amount Forecast')
  82. currency_id = fields.Many2one('res.currency', 'Currency')
  83. planner = fields.Char('Planner')