Pass object fields and one2many fields on same method - Odoo v8

Pass object fields and one2many fields on same method - Odoo v8

By : Minghao Pu
Date : November 23 2020, 03:01 PM
Does that help First if you call this method from the button no need to fetch any record because self (RecordSet) will contain only that record but it's better to loop any way if you want to call this method in using odoo-API.
code :
def @api.multi
def create_print(self,vals):
    # first define the empty model to call create from
    copy_record = self.env['other.model'] # now you call the method directly
    for record in self:
        # like this is safer
        # here create a list of cammands for you new o2m_field

        o2m_field = []
        for rec in record.o2m_field:
            # here loop through all o2m record to create the list of commands
                'some_field': rec.some_field,
                'some_field2': rec.some_field2,
                'some_m2o_field': rec.some_m2o_field.id,# m2o pass interger value
                # hope you don't have o2m_field here too. or you need to use imagination to create
                # a good method that creates this list of commands.

        # now create the record
          'simple_field' : record.simple_field, # for simple field type char,date,...
          'm2o_field': record.m2o_field.id, # pass the id always
          'o2m_field': o2m_field, # here we pass the list of commands that we created earlier

Share : facebook icon twitter icon
Odoo / OpenERP Display fields of one2many

Odoo / OpenERP Display fields of one2many

By : bres
Date : March 29 2020, 07:55 AM
wish of those help In the end, I managed to get what I wanted through delegation:
In my class.py:
code :
class sample (osv.osv):
    _inherits = { 'res.partner' : 'partner_id'}
Group by in one2many Fields in Odoo-8

Group by in one2many Fields in Odoo-8

By : gourav jain
Date : March 29 2020, 07:55 AM
it should still fix some issue The group by is possible only in tree views, not in One2many fields. Unfortunately.
Odoo - Combine two fields heading in one2many

Odoo - Combine two fields heading in one2many

By : Fahad
Date : March 29 2020, 07:55 AM
I hope this helps . First create the xml file which extends the ListView Template like this to add colspan feature in base list view template.
code :
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<div t-extend="ListView">
     <t t-jquery="table" t-operation="replace">
        <table class="o_list_view table table-condensed table-striped">
        <t t-set="columns_count" t-value="visible_columns.length + (options.selectable ? 1 : 0) + (options.deletable ? 1 : 0)"/>
            <tr t-if="options.header">
                <t t-foreach="columns" t-as="column">
                    <th t-if="column.meta">
                        <t t-esc="column.string"/>
                <th t-if="options.selectable" class="o_list_record_selector" width="1">
                    <div class="o_checkbox">
                        <input type="checkbox"/><span/>
                <t t-set="col" t-value="0"/>
                <t t-foreach="columns" t-as="column">
                    <t t-if="col == 0">
                    <th t-if="!column.meta and column.invisible !== '1'" t-att-data-id="column.id"
                        t-attf-class="text-center #{((options.sortable and column.sortable and column.tag !== 'button') ? 'o_column_sortable' : '')}"
                            t-att-width="column.width()" t-att-colspan="column.colspan" >
                        <t t-set="col" t-value="column.colspan or 1"/>    
                        <t t-if="column.tag !== 'button'"><t t-raw="column.heading()"/></t>
                    <t t-if="col !== 0" t-set="col" t-value="col - 1"/>
                <th t-if="options.deletable" class="o_list_record_delete"/>
                <td t-if="options.selectable"/>
                <td t-foreach="aggregate_columns" t-as="column" t-att-data-field="column.id" t-att-title="column.label">
                <td t-if="options.deletable" class="o_list_record_delete"/>
'qweb': [
    <field name="any_field" colspan="2"/>
How to change fields.One2Many view in odoo 12?

How to change fields.One2Many view in odoo 12?

By : streamer45
Date : March 29 2020, 07:55 AM
hope this fix your issue i trying to create fields.One2Many for my invoice module, i create two different module, one called ms_produk and another called invoice, then for the ms_produk i use as master product, which serve CRUD for item and have a table named "ms_produk_ms_produk" , Change the newly added section as,
code :
       <record id="salesorder_tree" model="ir.ui.view">
        <field name="name">salesorder.form.tree</field>
        <field name="model">salesorder.salesorder</field>
        <field name="type">tree</field>
        <field name='arch' type="xml">
            <field name='details'>
               <tree string="SalesOrder" editable="bottom">
                  <field name="kd_produk"/>
                  <field name="nm_produk"/>
Odoo: how to show fields of a many2one fields which is inside a one2many field

Odoo: how to show fields of a many2one fields which is inside a one2many field

By : user3520442
Date : March 29 2020, 07:55 AM
this will help I don't know how to put it but here's what i want, i want to show the fields of a custom.product model in the tree view of a one2many field my code is as follows , Add related field for fields you want to display in the tree view.
code :
class CustomSaleLine(models.Model):
    _name = 'custom.sale.line'
    _description = 'Sales Line'

    order_id = fields.Many2one('custom.sale', string='Order Reference', required=True,)

    product_id = fields.Many2one('custom.product', string='Product', change_default=True, ondelete='restrict')
    product_uom_qty = fields.Integer(string='Ordered Quantity', required=True, )
    brand_id = fields.Many2one('BRAND_MODEL_HERE',related='product_id.brand_id')
    country_id = fields.Many2one('COUNTRY_MODEL_HERE',related='product_id.country_id')
    sell_price = fields.Float(related='product_id.sell_price')

<record id="form_custom_sale" model="ir.ui.view">
    <field name="name">custom.sale.form</field>
    <field name="model">custom.sale</field>
    <field name="arch" type="xml">
        <form string="Sales">
                        <field name="name"/>
                    <page string="Order Lines" name="order_lines">
                        <field name="order_line" widget="section_and_note_one2many" mode="tree">
                            <tree editable="bottom">
                                    <create string="Add a product"/>
                                <field name="product_id">
                                <field name="brand_id"/>
                                <field name="country_id"/>
                                <field name="sell_price"/>
                                <field name="product_uom_qty" string="Ordered Qty"/>
Related Posts Related Posts :
  • How to calculate each single element of a numpy array based on conditions
  • How do I change the width of Jupyter notebook's cell's left part?
  • Measure distance between lat/lon coordinates and utm coordinates
  • Installing megam for NLTK on Windows
  • filter dataframe on each value of a samn column have a specific value of another column in Panda\Python
  • Threading with pubsub throwing AssertionError: 'callableObj is not callable' in wxPython
  • Get grouped data from 2 dataframes with condition
  • How can I import all of sklearns regressors
  • How to take all elements except the first k
  • Whats wrong with my iteration list of lists from csv
  • Tensorflow Estimator API save image summary in eval mode
  • How to Pack with PyQt - how to make QFrame/Layout adapt to content
  • How do I get certain Time Range in Python
  • python doubly linked list - insertAfter node
  • Open .h5 file in Python
  • Joining a directory name with a binary file name
  • python, sort list with two arguments in compare function
  • Is it possible to print from Python using non-ANSI colors?
  • Pandas concat historical data using date minus some number of days
  • CV2: Import Error in Python OpenCV
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org