考虑一下:
is_book_block
如果指定位置有足够的产品数量(isbn),请将文档状态更改为True
,并将布尔字段state
更改为class bsi_print_order(models.Model):
_name = 'bsi.print.order'
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('bsi.print.order') or '/'
return super(bsi_print_order, self).create(vals)
name = fields.Char('Reference', required=True, index=True, copy=False, readonly='True', default='New')
order_lines = fields.One2many('bsi.print.order.lines', 'print_order', string="Order lines")
book_block = fields.Boolean(string="Book Block", default=True)
binding = fields.Boolean(string="Binding")
edging = fields.Boolean(string="Edging")
state = fields.Selection([
('draft','Draft'),
('awaitingraw','Awaiting raw materials'),
('work_in_progress','Print in Progress'),
('delivered','Delivered'),
('cancel','Cancel'),
], string="State")
。
is_book_block
字段位于父模型上:
One2many order_lines field
class bsi_print_order_lines(models.Model):
_name = 'bsi.print.order.lines'
print_order = fields.Many2one('bsi.print.order', string="Print Order")
isbn = fields.Many2one('product.product', string="ISBN", domain="[('is_isbn', '=', True)]")
qty = fields.Integer(string="Quantity")
consumed_qty = fields.Integer(string="Quantity consumed")
remaining_qty = fields.Float(string="Remaining quantity")
is_book_block = fields.Boolean(string="Is Book Block Done")
is_binding = fields.Boolean(string="Is Binding Done")
is_edging = fields.Boolean(string="Is Edging Done")
isbns = fields.Many2one('worksheets.isbns', string="Worksheet ISBNS")
字段位于子类is_binding
上:
is_edging
还有其他两个字段state
和is_book_block
。
无论如何,知道一个足以弄清楚其他两个(我猜,大声笑)所以,因为True
在父类上,它运作良好,记录的状态实际上发生了变化, order_lines
没有语法错误,它应该更改为public class MyFirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onCreate() {
super.onCreate();
ShortcutBadger.applyCount(MyFirebaseMessagingService.this, 1);
}
}
,但它没有,所以,我认为这是因为该方法在var Dog = React.createClass({
bark: function() {
alert('bow');
},
render: function() {
return (<div>Dog</div>);
}
});
上循环,但它改变了一些东西仅限父类(bsi.production.order)。
有什么想法吗?
答案 0 :(得分:2)
根据我的理解,is_book_block
在行中循环时,每行都是一个记录,如果你想设置多于字段或只是改变那个字段,你就会调用write:
# when you change just one field no need for write just
rec.state = 'work_in_progress' # is enough
# because rec.state will trigger write method
# but for more than one field use write to trigger it only one time
# line is a record too you can call write also if you want
line.is_book_block = True
有一件事从onchange装饰器中移除order_lines.is_book_block
,因为你将触发对该方法的不定式调用:
@api.onchange('order_lines')