Skip to Content
Menu
This question has been flagged
2113 Views
While using these codes I am not able to save the data after clicking button on loadingslip. Is there any way to do that?
ORM code:
from odoo import models, fields, api

class sale_customer(models.Model):
_inherit='res.partner'
pan_number=fields.Char(string='PAN Number')
vat_number = fields.Char(string='VAT Number')
bank_name = fields.Char(string='Bank Name')
acc_number = fields.Char(string='Account Number')
# p = fields.Char(string='Verification Status')
contrat_start=fields.Date(string='Contract start Date')
contract_status=fields.Selection(
[('', ''), ('yes', 'Yes'),('no', 'No')],
default='', string='Contract Status')
key_person=fields.Char(string='Key Person')

mobile_no=fields.Char(string='Mobile Number')


class sale_code(models.Model):
_inherit='sale.order'
add=fields.Char(string='Address')

@api.multi
def open_second_class(self):
ac = self.env['ir.model.data'].xmlid_to_res_id('agni_loading_dharma_bharpai.loadingslip_form_12', raise_if_not_found=True)
tbl1 = False
for
o in self:
tbl1 = o.id
result = {
'name': '2nd class',
'view_type': 'form',
'res_model': 'loadingslip',
'view_id': ac,
'context': {'default_id_so': tbl1},
'type': 'ir.actions.act_window',
'view_mode': 'form'
}
return result

@api.multi
def open_third_class(self):
ac = self.env['ir.model.data'].xmlid_to_res_id('agni_loading_dharma_bharpai.dharmakata_form_12', raise_if_not_found=True)
tbl1 = False
for
o in self:
tbl1 = o.id
result = {
'name': '3rd class',
'view_type': 'form',
'res_model': 'dharmakata',
'view_id': ac,
'context': {'default_id_tbl1': tbl1},
'type': 'ir.actions.act_window',
'view_mode': 'form'
}
return result

@api.multi
def open_fourth_class(self):
ac = self.env['ir.model.data'].xmlid_to_res_id('agni_loading_dharma_bharpai.bharpai_form_12', raise_if_not_found=True)
tbl1 = False
for
o in self:
tbl1 = o.id
result = {
'name': '4th class',
'view_type': 'form',
'res_model': 'bharpai',
'view_id': ac,
'context': {'default_id_sb': tbl1},
'type': 'ir.actions.act_window',
'view_mode': 'form'
}
return result


class loadingslip(models.Model):
_name='loadingslip'
_description='loading information'
_inherits={'sale.order':'id_so'}
id_so=fields.Many2one('sale.order')
truck_no=fields.Integer(string='Truck Number')
# name1=fields.Char(string="Name")


class dharmakata(models.Model):
_name='dharmakata'
sale_o=fields.Many2one('sale.order',string='Sale Order')
bag=fields.Integer(string='No. of Bags')
b_wt=fields.Char(string='Weight Before Loading')
a_wt = fields.Char(string='Weight After Loading',compute = '_value_gratio')

@api.depends('bag')
def _value_gratio(self):
# if self.sales > 0:
self.a_wt = float(self.bag) * 50


class bharpai(models.Model):
_name='bharpai'
_inherits = {'sale.order': 'id_sb'}
id_sb = fields.Many2one('sale.order')
truck_no = fields.Integer(string='Truck Number')

view code:
<odoo>
<data>
<record id="sale.order_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/*" position="before">
<header>
<button name="open_second_class" type="object" string="loadingslip" />
<button name="open_third_class" type="object" string="Dharmakata" />
<button name="open_fourth_class" type="object" string="Bharpai" />
</header>
</xpath>
</field>
</record>


<record id="loadingslip_form_12" model="ir.ui.view">
<field name="name">loadingslip.form.12</field>
<field name="model">loadingslip</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Mymodule" duplicate="false">
<group>
<field name="state" invisible="1"/>

<field name="id_so"/>
<field name="partner_id" />
<field name="date_order" />
<field name="truck_no"/>
</group>
<notebook>
<page string="Order Lines">
<field name="order_line" mode="tree,kanban">


<tree string="Sales Order Lines" editable="bottom" decoration-info="invoice_status=='to invoice'">

<field name="product_id"/>


<field name="product_uom_qty"/>

</tree>

</field>

</page>

</notebook>

</form>
</field>
</record>


<record id="loadingslip_tree_12" model="ir.ui.view">
<field name="name">loadingslip.tree.12</field>
<field name="model">loadingslip</field>
<field name="type">form</field>
<field name="arch" type="xml">
<tree string="Mymodule" export="false">
<field name="name"/>
<field name="partner_id" />
<field name="date_order" />
<field name="validity_date" />
</tree>
</field>
</record>


<record id="dharmakata_form_12" model="ir.ui.view">
<field name="name">dharmakata.form.12</field>
<field name="model">dharmakata</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Mymodule" duplicate="false">
<group>
<group>
<field name="sale_o"/>
</group>
<group>
</group>

</group>
<group>
<group>

<field name="b_wt"/>
</group>
<group>
<field name="bag"/>
<field name="a_wt"/>
</group>
</group>
</form>
</field>
</record>




<record id="bharpai_form_12" model="ir.ui.view">
<field name="name">bharpai.form.12</field>
<field name="model">bharpai</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Mymodule" duplicate="false">
<group>

<field name="id_sb"/>



<field name="partner_id" />
<field name="date_order" />

<field name="truck_no"/>
</group>
<notebook>
<page string="Order Lines">
<field name="order_line" mode="tree,kanban" attrs="{'readonly': [('state', 'in', ('done','cancel'))]}">

<tree string="Sales Order Lines" editable="bottom" decoration-info="invoice_status=='to invoice'">

<field name="product_id"/>

<field name="product_uom_qty" string="Ordered Qty" />

</tree>

</field>

</page>

</notebook>

</form>
</field>
</record>




<act_window id="action_loadingslip" name ="loading_slip" res_model="loadingslip" view_mode="tree,form"/>
<menuitem id ="menu_loadingslip" parent="sale.menu_sale_invoicing" sequence="20" action="action_loadingslip"/>

</data>
</odoo>
Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
25098
2
May 24
5519
3
Mar 24
4964
0
Mar 24
264
3
Feb 24
11421