|
@ -27,6 +27,13 @@ class BeesdooProduct(models.Model): |
|
|
|
|
|
|
|
|
note = fields.Text('Comments') |
|
|
note = fields.Text('Comments') |
|
|
|
|
|
|
|
|
|
|
|
# S0023 : List_price = Price HTVA, so add a suggested price |
|
|
|
|
|
list_price = fields.Float(string='exVAT Price') |
|
|
|
|
|
suggested_price = fields.Float(string='Suggested exVAT Price', compute='_compute_cost', readOnly=True) |
|
|
|
|
|
|
|
|
|
|
|
def _get_main_supplier_info(self): |
|
|
|
|
|
return self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True) |
|
|
|
|
|
|
|
|
@api.one |
|
|
@api.one |
|
|
def generate_barcode(self): |
|
|
def generate_barcode(self): |
|
|
print 'generate barcode', self.barcode, self.barcode == '' |
|
|
print 'generate barcode', self.barcode, self.barcode == '' |
|
@ -45,7 +52,7 @@ class BeesdooProduct(models.Model): |
|
|
@api.depends('seller_ids', 'seller_ids.date_start') |
|
|
@api.depends('seller_ids', 'seller_ids.date_start') |
|
|
def _compute_main_seller_id(self): |
|
|
def _compute_main_seller_id(self): |
|
|
# Calcule le vendeur associé qui a la date de début la plus récente et plus petite qu’aujourd’hui |
|
|
# Calcule le vendeur associé qui a la date de début la plus récente et plus petite qu’aujourd’hui |
|
|
sellers_ids = self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True) |
|
|
|
|
|
|
|
|
sellers_ids = self._get_main_supplier_info() # self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True) |
|
|
self.main_seller_id = sellers_ids and sellers_ids[0].name or False |
|
|
self.main_seller_id = sellers_ids and sellers_ids[0].name or False |
|
|
|
|
|
|
|
|
@api.one |
|
|
@api.one |
|
@ -70,6 +77,13 @@ class BeesdooProduct(models.Model): |
|
|
if self.display_unit.category_id != self.default_reference_unit.category_id: |
|
|
if self.display_unit.category_id != self.default_reference_unit.category_id: |
|
|
raise UserError(_('Reference Unit and Display Unit should belong to the same category')) |
|
|
raise UserError(_('Reference Unit and Display Unit should belong to the same category')) |
|
|
|
|
|
|
|
|
|
|
|
@api.one |
|
|
|
|
|
@api.depends('seller_ids') |
|
|
|
|
|
def _compute_cost(self): |
|
|
|
|
|
suppliers = self._get_main_supplier_info() |
|
|
|
|
|
if(len(suppliers) > 0): |
|
|
|
|
|
self.suggested_price = (suppliers[0].price * self.uom_po_id.factor)* (1 + suppliers[0].product_tmpl_id.categ_id.profit_margin / 100) |
|
|
|
|
|
|
|
|
class BeesdooProductLabel(models.Model): |
|
|
class BeesdooProductLabel(models.Model): |
|
|
_name = "beesdoo.product.label" |
|
|
_name = "beesdoo.product.label" |
|
|
|
|
|
|
|
@ -77,3 +91,19 @@ class BeesdooProductLabel(models.Model): |
|
|
type = fields.Selection([('eco', 'Écologique'), ('local', 'Local'), ('fair', 'Équitable'), ('delivery', 'Distribution')]) |
|
|
type = fields.Selection([('eco', 'Écologique'), ('local', 'Local'), ('fair', 'Équitable'), ('delivery', 'Distribution')]) |
|
|
color_code = fields.Char() |
|
|
color_code = fields.Char() |
|
|
|
|
|
|
|
|
|
|
|
class BeesdooProductCategory(models.Model): |
|
|
|
|
|
_inherit = "product.category" |
|
|
|
|
|
|
|
|
|
|
|
profit_margin = fields.Float(default = '10.0', string = "Product Margin [%]") |
|
|
|
|
|
|
|
|
|
|
|
@api.one |
|
|
|
|
|
@api.constrains('profit_margin') |
|
|
|
|
|
def _check_margin(self): |
|
|
|
|
|
if (self.profit_margin < 0.0): |
|
|
|
|
|
raise UserError(_('Percentages for Profit Margin must > 0.')) |
|
|
|
|
|
|
|
|
|
|
|
class BeesdooProductSupplierInfo(models.Model): |
|
|
|
|
|
_inherit = "product.supplierinfo" |
|
|
|
|
|
|
|
|
|
|
|
price = fields.Float('exVAT Price') |
|
|
|
|
|
|