新手上路,遇到问题,求助各位大神
-
明细有数据时,主档的书店不让编辑
class st_book4(models.Model): _name = 'st.book4' _description = u'书箱出库' name = fields.Char(u'单据编码', default=False) date = fields.Date(u'日期') state = fields.Selection([('draft',u'草稿'),('done',u'确定'), ],u'状态', readonly=False, required=True, default='draft') book4_id = fields.Many2one('st.bookstore', u'书店', required=False,) storage3_ids = fields.One2many('st.storage2', 'master2_id', u'入库明细', required=False)
上面是book4,是主档代码
下面是明细字段:class st_storage2(models.Model): _name = 'st.storage2' _description = u'出库详细' code = fields.Char(u'序号', default=False) number = fields.Float(u'出库数量', digits=(16, 2)) master2_id = fields.Many2one('st.book4', u'书箱入库', required=False,) aaa_id = fields.Many2one('st.book3', u'书目', required=False,) name = fields.Char(related='aaa_id.name',string=u'书名', default=False) samount = fields.Float(u'销售单价',related='aaa_id.samount', digits=(16, 2)) to_pri = fields.Float(u'销售总价', digits=(16, 2)) amount = fields.Float(u'单价',related='aaa_id.amount', digits=(16, 2)) tatol = fields.Float(u'金额',related='aaa_id.tatol', digits=(16, 2))
-
st.book4.tree st.book4
<record id="view_st_book4_form" model="ir.ui.view"> <field name="name">st.book4.form</field> <field name="model">st.book4</field> <field name="priority" eval="8" /> <field name="arch" type="xml"> <form string="书箱出库"> <sheet> <header> <button name="action_done" states="draft" string="确定" type="object" class="oe_highlight" /> <button name="action_deft" states="done" string="草稿" type="object" class="oe_highlight" /> </header> <group colspan="4" col="4"> <field name="name" /> <field name="date" /> <field name="book4_id" /> <field name="state" /> </group> <notebook> <!--<page name="note" string="备注">--> <!--<field name="note"/>--> <!--</page>--> <page name="书目" string="书目"> <field name="storage3_ids" > <tree editable="bottom" create="true" delete="true"> <field name="code" /> <field name="aaa_id" /> <field name="name" /> <field name="number"/> <field name="samount"/> <field name="to_pri"/> <field name="number_s"/> </tree> <form> <group> <field name="code" /> <field name="aaa_id" /> <field name="name" /> <field name="number"/> <field name="samount"/> <field name="to_pri"/> <field name="number_s"/> <field name="amount"/> <field name="tatol"/> </group> </form> </field> </page> </notebook> </sheet> </form> </field> </record>
-