Odoo Help

0

0
2 Risposte
0

def action_invoice_create(self, cr, uid, ids, group=False, context=None):
    context = dict(context or {})
    repair = self.browse(cr, uid, ids[0], context)
    context['default_fleet_id'] = repair.fleet_id and repair.fleet_id.id or False
    res = super(mrp_repair, self).action_invoice_create(
        cr, uid, ids, group=group, context=context)

I've added the code listed above, which resulted in this code below:


def action_invoice_create(self, cr, uid, ids, group=False, context=None):
    print "action_invoice_create---------------",ids, group, context
    context = dict(context or {})
    repair = self.browse(cr, uid, ids[0], context)
    context['fleet_id'] = repair.fleet_id and repair.fleet_id.id or False
    res = super(mrp_repair, self).action_invoice_create(cr, uid, ids,
                                                        group=group,
                                                        context=context)
    inv_line_obj = self.pool.get('account.invoice.line')
    inv_obj = self.pool.get('account.invoice')
    for repair_id, invoice_id in res.iteritems():
        if not invoice_id:
            continue
        invoice  = inv_obj.browse(cr, uid, invoice_id) #activated by MSKE-25/06/2016
        inv_obj.write(cr, uid, [invoice_id],{'fleet_id': fleet_id}) # added by MSKE-25/06/2016
        for rsol in repair.order_line_ids:
            name = rsol.name or ''

            if rsol.product_id.property_account_income:
                account_id = rsol.product_id.property_account_income.id
            elif rsol.product_id.categ_id.property_account_income_categ:
                account_id = rsol.product_id.categ_id.property_account_income_categ.id
            else:
                raise osv.except_osv(_('Error!'), _('No account defined for product "%s".') % rsol.product_id.name)
            invoice_line_vals = {
                'invoice_id': invoice_id,
                'name': rsol.product_id.name,
                'origin': rsol.repair_sale_order_line_id.name,
                'account_id': account_id,
                #'quantity': rsol.product_uom_qty,
                'invoice_line_tax_id': [(6, 0, [x.id for x in rsol.tax_id])],
                'uos_id': rsol.product_id.uom_id.id,
                'price_unit': rsol.price_unit,
                'price_subtotal': rsol.product_uom_qty * rsol.price_unit,
                'product_id': rsol.product_id and rsol.product_id.id or False
            }

            print "invoice_line_vals----------",invoice_line_vals

            invoice_line_id = inv_line_obj.create(cr, uid, invoice_line_vals)
            print "after line create----------------------------",invoice_line_id
        self.pool.get('account.invoice').\
            button_reset_taxes(cr, uid, invoice_id, context=context)
    return res

But i'm receiving the error:

ValueError: "null value in column "fleet_id" violates not-null constraint

Any advice? Where did i go wrong

1 Commento
Mohammed Kamar-eddine Marocco
25/06/16, 10:55

THE ERROR im receiving now:

Odoo Server Error

Traceback (most recent call last):

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 539, in _handle_exception

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 576, in dispatch

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 312, in _call_function

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\service\model.py", line 118, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 309, in checked_call

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 805, in __call__

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 405, in response_wrap

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\openerp\addons\web\controllers\main.py", line 955, in exec_workflow

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 1113, in exec_workflow

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 881, in proxy_method

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\http.py", line 115, in dispatch_rpc

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\service\model.py", line 37, in dispatch

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\service\model.py", line 118, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\service\model.py", line 188, in exec_workflow

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\service\model.py", line 182, in exec_workflow_cr

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\service\model.py", line 164, in execute_cr

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 268, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\models.py", line 3571, in signal_workflow

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\__init__.py", line 85, in trg_validate

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\service.py", line 91, in validate

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\instance.py", line 80, in validate

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 120, in process

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 248, in _split_test

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 257, in _join_test

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 95, in create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 116, in process

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 162, in _execute

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 313, in wkf_expr_execute

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\workflow\workitem.py", line 291, in wkf_expr_eval_expr

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\tools\safe_eval.py", line 314, in safe_eval

File "", line 1, in <module>

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 266, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 564, in new_api

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\openerp\addons\mrp_repair\mrp_repair.py", line 306, in wkf_invoice_create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 268, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\openerp\addons\garage\objects\mrp_repair.py", line 558, in action_invoice_create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 268, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\openerp\addons\mrp_repair\mrp_repair.py", line 351, in action_invoice_create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 268, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\openerp\addons\garage\objects\invoice.py", line 50, in create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 268, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\openerp\addons\mail\mail_thread.py", line 381, in create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 268, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 372, in old_api

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\models.py", line 4093, in create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 266, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\api.py", line 508, in new_api

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\models.py", line 4231, in _create

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\sql_db.py", line 158, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20160420\server\.\openerp\sql_db.py", line 234, in execute

ValueError: "null value in column "fleet_id" violates not-null constraint

DETAIL: Failing row contains (2, null, null, 0.00, null, null, null, null, 1, 113, 2016-06-25 14:54:53.655, 1, null, null, null, 296, null, none, 2, null, draft, null, out_invoice, null, 1179, f, null, null, null, null, 2016-06-25 14:54:53.655, 1, 1, OR-003, null, OR-003, f, null, null, 1, null, null, null).

" while evaluating

u'wkf_invoice_create()'

0
Avatar

ayman mohammed adam Arabia Saudita

--ayman mohammed adam--
--ayman mohammed adam--


ayman mohammed adam Arabia Saudita
25/06/16, 05:32

Dear all,

you must add 

fleet_id field  many2one on account.invoice Model and then update this field on created invoice  



def action_invoice_create(self, cr, uid, ids, group=False, context=None):
        print "action_invoice_create---------------",ids, group, context
        repair = self.browse(cr, uid, ids[0])
        res = super(mrp_repair, self).action_invoice_create(cr, uid, ids,
                                                            group=group,
                                                            context=context)
        inv_line_obj = self.pool.get('account.invoice.line')
        inv_obj = self.pool.get('account.invoice')
        for repair_id, invoice_id in res.iteritems():
            if not invoice_id:
                continue

                        invoice = inv_obj.browse(cr, uid, invoice_id)
                        inv_obj.write(cr, uid, [invoice_id],{'fleet_id':your fleet _id})
Fai una domanda
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now