37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import models, fields, api
|
|
|
|
|
|
class TxProduct(models.Model):
|
|
_name = 'tx.product'
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_description = '产品'
|
|
|
|
def _domain_tag_ids(self):
|
|
return [("parent_id", "=", self.env['ir.model.data']._xmlid_to_res_id('tx_cms_upgrade.data_dict_product_tag')),
|
|
("category", "=", "value")]
|
|
|
|
name = fields.Char(string='名称', tracking=True)
|
|
company_name = fields.Char(string='公司名称', tracking=True)
|
|
tag_ids = fields.Many2many("tx.data.dict", string="产品标签", domain=lambda self: self._domain_tag_ids(), tracking=True)
|
|
brief_introduction = fields.Html(string="简介", tracking=True)
|
|
price = fields.Float(string="价格", tracking=True)
|
|
state = fields.Selection([
|
|
("draft", "草稿"),
|
|
("approve", "待审核"),
|
|
("pass", "通过"),
|
|
("reject", "驳回")], string="状态", default="draft", tracking=True)
|
|
|
|
def action_draft(self):
|
|
self.write({"state": "draft"})
|
|
|
|
def action_approve(self):
|
|
self.write({"state": "approve"})
|
|
|
|
def action_pass(self):
|
|
self.write({"state": "pass"})
|
|
|
|
def action_reject(self):
|
|
self.write({"state": "reject"})
|