|
- # -*- coding: utf-8 -*-
- from odoo import models, fields, api
- from odoo.exceptions import ValidationError
- from odoo.exceptions import UserError
-
- # 销货订单确认状态可选值
- ORDER_STATES = [
- ('draft', '草稿'),
- ('done', '已确认'),
- ('in', '已入库'),
- ('cancel', '已作废')]
-
- # 字段只读状态
- READONLY_STATES = {
- 'done': [('readonly', True)],
- 'allocated': [('readonly', True)],
- 'cancel': [('readonly', True)],
- }
-
-
- class Arrival_advices(models.Model):
- _name = 'arrival.advices'
- _description = '到货报告单'
-
- order_line = fields.One2many('purchase.order.line', 'order_id', states={'cancel': [('readonly', True)]})
-
- partner_id = fields.Many2one('res.partner', required=True, states=READONLY_STATES)
-
- company_id = fields.Many2one('res.company', 'Company', required=True, index=True, states=READONLY_STATES)
-
-
- state = fields.Selection(ORDER_STATES, '确认状态', readonly=True,
- help="到货通知单的确认状态", index=True,
- copy=False, default='draft')
-
-
- class Arrival_advices_line(models.Model):
- _name ='arrival.advices.line'
- _description ='到货通知'
-
- notice_id = fields.Many2one('arrival.advices', index=True, string="通知号",ondelete='cascade')
-
- product_id = fields.Many2one('purchase.order.line','产品' ,ondelete='cascade',required=True,
- help='对应的购货订单行')
- lot = fields.Char('批次')
- qty = fields.Float('商品数量')
|