Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to solve product.uom error

By
Aijay Ogbugha
on 7/2/13, 10:24 AM 2,999 views

Hey guys, I created a form to receive data for a store. But on clicking the "save" button, i get this error: except_osv: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: Product Unit of Measure - product.uom]')

I really don't know why this error since i didn't inherit any object except the "mail.thread" object. Please i need help concerning this. It has really taken my time and i have limited time to deliver. And I don't know where else to look to solve it.

Any help will be appreciated please.

class store_products(osv.osv):
    _name='store.products'
    _description='Store Products'
    _inherit=['mail.thread']
    _columns={
         'name': fields.char('Description', size=128, required=True, translate=True, select=True),
         'my_product_id': fields.many2one('product.product', 'Product', required=True, select=True),
         'product_qty': fields.integer('Quantity', required=True, track_visibility='onchange'),
         'store_product_id': fields.many2one('store.issuing.voucher', 'Products'),
         'value': fields.float('Value (NGN)', size=32,track_visibility='onchange'),
         #'account_code': fields.char('Account Code', size=32, readonly=False, required=True, track_visibility='onchange'),
         'account_code': fields.many2one('account.account', 'Account Code', required=True, track_visibility='onchange',
                                          help="The partner account used for this invoice."),
           }
store_products()


class store_issuing_voucher(osv.osv):
    _name = "store.issuing.voucher"
    _inherit = [ 'mail.thread']
    _description = "The Store Issuing Voucher"

    _columns={
          'employee_id': fields.many2one('hr.employee', 'Requestor', required=False,track_visibility='onchange'),
          'department_id': fields.many2one('hr.department', 'Department', required=False, track_visibility='onchange'),
          'organizational_id': fields.many2one('store.voucher.organization', 'Organizational Code', required=False, track_visibility='onchange'),
          'fund_code': fields.char('Fund Code', size=32, readonly=False, required=False, track_visibility='onchange'),
          'program_code': fields.char('Program Code', size=32, readonly=False, required=False, track_visibility='onchange'),
          'location_code': fields.char('Location Code', size=32, readonly=False, track_visibility='onchange'),
          'manager_id': fields.many2one('hr.employee', 'Store Voucher Present Manager', required=False, track_visibility='onchange'),              
          'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
          'date': fields.datetime('Date', require=True, select=True),
          'mystore_product_ids': fields.one2many('store.products', 'store_product_id', 'Store Product Lines'),
          'value': fields.float('Value (NGN)', size=32,track_visibility='onchange'),
          'note': fields.text('Notes'),
}
store_issuing_voucher()

XML :

<record id="store_issuing_voucher_form" model="ir.ui.view">
        <field name="name">store.issuing.voucher.form</field>
        <field name="model">store.issuing.voucher</field>
        <field name="arch" type="xml">
            <form string="Store Issuing Voucher" version="7.0">
                    <sheet string="Store Issuing Voucher">
                        <group string="Requestor Details" col="4">
                            <field name="employee_id" on_change="onchange_employee_id(employee_id,department_id)" />
                            <field name="department_id"/>
                            <field name="date" />
                            <field name="organizational_id"  />
                            <field name="fund_code"  />
                            <field name="program_code"  />
                            <field name="location_code"  />
                            <field name="manager_id" />                                 
                        </group>
                    <group string="Product Item Details">
                        <notebook>
                            <page string="Store Products Lines">
                                <field name= "mystore_product_ids" />
                                <field name="note" placeholder="Add any note..." class="oe_inline" />
                            </page>
                        </notebook> 
                    </group>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
            </form>
        </field>
    </record>
    <!-- End of Store Issuing Voucher Form View -->

     <!-- Store Issuing Voucher tree View -->

    <record id="store_issuing_voucher_tree" model="ir.ui.view">
        <field name="name">store.issuing.voucher.tree</field>
        <field name="model">store.issuing.voucher</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Vouchers" >
              <!--  <field name="my_product_id"/>  -->
                <field name="employee_id"/>
                <field name="department_id" />
                <field name="organizational_id"/>
                <field name="program_code"/>
                <field name="value"/>
                <field name="date"/>
            </tree>
        </field>
    </record>

 <record id="store_products_form" model="ir.ui.view">
        <field name="name">store.products.form</field>
        <field name="model">store.products</field>
        <field name="arch" type="xml">
            <form string="Store Product Lines" version="7.0">
                <sheet>
                    <group col="4">
                        <field name="account_code"/>
                      <field name="my_product_id" on_change="onchange_my_product_id(my_product_id)"/>  
                      <!-- <field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
                        <field name="name"/>-->
                        <field name="product_qty"/>
                        <field name="value"/>
                    </group>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
            </form>

 <record id="store_products_tree" model="ir.ui.view">
        <field name="name">store.products.tree</field>
        <field name="model">store.products</field>
        <field name="arch" type="xml">
            <tree string="Store Products">
                <field name="account_code"/>
                <field name="my_product_id"/>
                <field name="product_qty"/> 
                <field name="value"/>
            </tree>
        </field>
   </record>

paste your code over here.

Ghanshyam Prajapati
on 7/2/13, 10:31 AM

Canyou post your XML as well in the original question?

patrick
on 7/2/13, 11:36 AM

I have posted both py and xml files. thanks

Aijay Ogbugha
on 7/2/13, 11:47 AM
0
Aijay Ogbugha
On 7/2/13, 11:00 AM
class store_products(osv.osv):
    _name='store.products'
    _description='Store Products'
    _inherit=['mail.thread']
    _columns={
         'name': fields.char('Description', size=128, required=True, translate=True, select=True),
         'my_product_id': fields.many2one('product.product', 'Product', required=True, select=True),
         'product_qty': fields.integer('Quantity', required=True, track_visibility='onchange'),
         'store_product_id': fields.many2one('store.issuing.voucher', 'Products'),
         'value': fields.float('Value (NGN)', size=32,track_visibility='onchange'),
         #'account_code': fields.char('Account Code', size=32, readonly=False, required=True, track_visibility='onchange'),
         'account_code': fields.many2one('account.account', 'Account Code', required=True, track_visibility='onchange',
                                          help="The partner account used for this invoice."),
           }
store_products()


class store_issuing_voucher(osv.osv):
    _name = "store.issuing.voucher"
    _inherit = [ 'mail.thread']
    _description = "The Store Issuing Voucher"

    _columns={
          'employee_id': fields.many2one('hr.employee', 'Requestor', required=False,track_visibility='onchange'),
          'department_id': fields.many2one('hr.department', 'Department', required=False, track_visibility='onchange'),
          'organizational_id': fields.many2one('store.voucher.organization', 'Organizational Code', required=False, track_visibility='onchange'),
          'fund_code': fields.char('Fund Code', size=32, readonly=False, required=False, track_visibility='onchange'),
          'program_code': fields.char('Program Code', size=32, readonly=False, required=False, track_visibility='onchange'),
          'location_code': fields.char('Location Code', size=32, readonly=False, track_visibility='onchange'),
          'manager_id': fields.many2one('hr.employee', 'Store Voucher Present Manager', required=False, track_visibility='onchange'),              
          'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
          'date': fields.datetime('Date', require=True, select=True),
          'mystore_product_ids': fields.one2many('store.products', 'store_product_id', 'Store Product Lines'),
          'value': fields.float('Value (NGN)', size=32,track_visibility='onchange'),
          'note': fields.text('Notes'),
}
store_issuing_voucher()

This is the py file

Aijay Ogbugha
on 7/2/13, 11:01 AM
0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 7/2/13, 10:31 AM

The error-message indicates that during deletion or creating/saving an error occured regarding consistency.

You say you want to save, so that means that your object somehow needs to know the uom (Unit Of Manufacturing). It might help, if you post your code in your question, so we can have a look how/what.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 7/2/13, 10:24 AM
Seen: 2999 times
Last updated: 3/16/15, 8:10 AM