Public release from ruodoo-project: 19.0 - 2026-05-10 21:19:01 UTC
This commit is contained in:
82
mklab_forecast_mrp/models/marketing.py
Normal file
82
mklab_forecast_mrp/models/marketing.py
Normal file
@ -0,0 +1,82 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api, exceptions
|
||||
|
||||
|
||||
class MklabMarketAction(models.Model):
|
||||
_name = 'mklab.marketaction'
|
||||
|
||||
name = fields.Char(
|
||||
string='Название акции',
|
||||
compute='_compute_name',
|
||||
store=True,
|
||||
)
|
||||
start_date = fields.Date(string='Дата начала отгрузок', required=True)
|
||||
end_date = fields.Date(string='Дата окончания отгрузок', required=True)
|
||||
start_sale_date = fields.Date(string='Дата начала продаж на полке', required=True)
|
||||
end_sale_date = fields.Date(string='Дата окончания продаж на полке', required=True)
|
||||
product_line_ids = fields.One2many(
|
||||
comodel_name='mklab.productline',
|
||||
inverse_name='action_id',
|
||||
string='Продукты',
|
||||
)
|
||||
partner_line_ids = fields.One2many(
|
||||
comodel_name='mklab.partnerline',
|
||||
inverse_name='action_id',
|
||||
string='Контрагенты',
|
||||
)
|
||||
|
||||
@api.constrains('start_date', 'end_date', 'start_sale_date', 'end_sale_date')
|
||||
def _check_dates(self):
|
||||
for s in self:
|
||||
if s.end_date < s.start_date:
|
||||
raise exceptions.ValidationError(
|
||||
'Дата начала отгрузок должна быть меньше даты окончания!')
|
||||
if s.end_sale_date < s.start_sale_date:
|
||||
raise exceptions.ValidationError(
|
||||
'Дата начала продаж на полке должна быть меньше даты окончания!')
|
||||
|
||||
@api.depends('start_date', 'end_date')
|
||||
def _compute_name(self):
|
||||
for s in self:
|
||||
s.name = str(s.start_date) if s.start_date and s.end_date else ''
|
||||
|
||||
|
||||
class MklabProductLine(models.Model):
|
||||
_name = 'mklab.productline'
|
||||
|
||||
action_id = fields.Many2one(
|
||||
comodel_name='mklab.marketaction',
|
||||
string='Акция',
|
||||
index=True,
|
||||
)
|
||||
product_id = fields.Many2one(
|
||||
comodel_name='product.product',
|
||||
string='Товар',
|
||||
required=True,
|
||||
index=True,
|
||||
)
|
||||
discount_ship = fields.Float(string='Скидка поставки', required=True)
|
||||
discount_sale = fields.Float(string='Скидка на полке', required=True)
|
||||
expected_growth = fields.Float(
|
||||
string='Ожидаемый рост продаж, %',
|
||||
required=True,
|
||||
default=20,
|
||||
)
|
||||
|
||||
|
||||
class MklabPartnerLine(models.Model):
|
||||
_name = 'mklab.partnerline'
|
||||
|
||||
action_id = fields.Many2one(
|
||||
comodel_name='mklab.marketaction',
|
||||
string='Акция',
|
||||
index=True,
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
string='Контрагент',
|
||||
required=True,
|
||||
index=True,
|
||||
)
|
||||
pos_qty = fields.Float(string='Процент точек', required=True)
|
||||
Reference in New Issue
Block a user