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 create a module compatible with all others modules ?

By
hellequin
on 2/14/14, 8:54 AM 908 views

I create a specific module wich modify module sale. he work when only sale module is installed. But when I add module CRM, my specific module don't work.

how to make it compatible?

This is my class ?

from osv import osv, fields

from openerp import netsvc import logging _logger = logging.getLogger(__name__)

class complement_sale_order(osv.osv):

_inherit = 'sale.order'

_defaults = {
    'x_num_devis' : lambda obj, cr, uid, context: '/',
    'x_num_commande' : lambda obj, cr, uid, context: '/',
}

_columns = {
    'x_num_devis' : fields.char('Numéro Devis', size=15),
    'x_num_commande' : fields.char('Numéro de commande', size=15),
    'state': fields.selection([
        ('draft', 'Draft Quotation'),
        ('sent', 'Quotation Sent'),
        ('x_approve_quotation', 'Demander approbation'),
        ('cancel', 'Cancelled'),
        ('waiting_date', 'Waiting Schedule'),
        ('progress', 'Sales Order'),
        ('manual', 'Sale to Invoice'),
        ('invoice_except', 'Invoice Exception'),
        ('done', 'Done'),
        ], 'Status', readonly=True, track_visibility='onchange',
        help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
}

def create(self, cr, uid, vals, context=None):
    if vals.get('x_num_devis','/')=='/':
        vals['x_num_devis'] = self.pool.get('ir.sequence').get(cr, uid, 'sequence.numero.devis') + '-A' or '/'
    return super(complement_sale_order, self).create(cr, uid, vals, context=context)

def copy_data(self, cr, uid, id, default=None, context=None):
    if not default:
        default = {}
    default.update({'x_num_devis' : self.pool.get('ir.sequence').get(cr, uid, 'sequence.numero.devis') + '-A',})
    return super(complement_sale_order, self).copy_data(cr, uid, id, default, context=context)

def test_mdel(self, cr, uid, ids, id, default=None, context=None):

    # on récupére les data 
    sale = self.browse(cr, uid, ids)
    for rec in sale:
        #v_create_uid = rec.create_uid
        #v_create_date = rec.create_date
        #v_write_date = rec.write_date
        #v_write_uid = rec.write_uid
        v_origin = rec.origin
        v_order_policy = rec.order_policy
        v_shop_id = rec.shop_id.id
        v_client_order_ref = rec.client_order_ref
        v_date_order = rec.date_order
        v_partner_id =rec.partner_id.id
        v_note = rec.note
        v_fiscal_position = rec.fiscal_position
        v_user_id = rec.user_id.id
        v_payment_term = rec.payment_term
        v_company_id = rec.company_id.id
        v_amount_tax = rec.amount_tax
        v_state = rec.state
        v_pricelist_id = rec.pricelist_id.id
        v_partner_invoice_id = rec.partner_invoice_id.id
        v_amount_untaxed = rec.amount_untaxed
        v_date_confirm = rec.date_confirm
        v_amount_total = rec.amount_total
        v_project_id = rec.project_id.id
        v_name = self.pool.get('ir.sequence').get(cr, uid, 'sale.order')
        v_partner_shipping_id = rec.partner_shipping_id.id
        v_invoice_quantity = rec.invoice_quantity
        v_picking_policy = rec.picking_policy
        v_incoterm = rec.incoterm
        v_shipped = rec.shipped
        v_carrier_id = rec.carrier_id.id
        v_section_id = rec.section_id.id
        v_num_commande = rec.x_num_commande
        v_num_devis = rec.x_num_devis

    #cr.execute("SELECT nextval('sale_order_id_seq') FROM sale_order")
    #next_id = cr.fetchone()[0]

    #cr.execute("INSERT INTO sale_order (create_uid,create_date,write_date,write_uid,origin,order_policy,shop_id,client_order_ref,date_order,partner_id,note,fiscal_position,user_id,payment_term,company_id,amount_tax,state,pricelist_id,partner_invoice_id,amount_untaxed,date_confirm,amount_total,project_id,name,partner_shipping_id,invoice_quantity,x_num_commande,x_num_devis) VALUES \
    #(%s,%s,%s,%s,%s,%s,%s,%s,(now() at time zone 'UTC'),%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",(vals.get('create_uid'),vals.get('create_date'),vals.get('write_date'),vals.get('write_uid'),vals.get('origin'),vals.get('order_policy') or 'manual',vals.get('shop_id') or 1,vals.get('client_order_ref'),vals.get('partner_id') or 5,vals.get('note'),vals.get('fiscal_position'),vals.get('user_id'),vals.get('payment_term'),vals.get('compagny_id'),vals.get('amount_tax'),vals.get('state'),vals.get('pricelist_id') or 1,vals.get('partner_invoice_id') or 5,vals.get('amount_untaxed'),vals.get('date_confirm'),vals.get('amount_total'),vals.get('project_id'),self.pool.get('ir.sequence').get(cr, uid, 'sale.order'),vals.get('partner_shipping_id') or 5,vals.get('invoice_quantity') or 'order',vals.get('x_num_commande'),vals.get('x_num_devis')))
    msg = "Test " +str(v_name) 
    new_id = self.pool.get('sale.order').create(cr, uid, {
        'origin':v_origin,
        'order_policy':v_order_policy,
        'shop_id':v_shop_id,
        'client_order_ref':v_client_order_ref,
        'date_order':v_date_order,
        'partner_id':v_partner_id,
        'note':v_note,
        'fiscal_position':v_fiscal_position,
        'user_id':v_user_id,
        'payment_term':v_payment_term,
        'company_id':v_company_id,
        'amount_tax':v_amount_tax,
        'state':v_state,
        'pricelist_id':v_pricelist_id,
        'partner_invoice_id':v_partner_invoice_id,
        'amount_untaxed':v_amount_untaxed,
        'date_confirm':v_date_confirm,
        'amount_total':v_amount_total,
        'project_id':v_project_id,
        'name':v_name,
        'partner_shipping_id':v_partner_shipping_id,
        'invoice_quantity':v_invoice_quantity,
        'picking_policy':v_picking_policy,

        'x_num_commande':v_num_commande,
        'x_num_devis':v_num_devis
        })

    _logger.error(msg)
    v_num_devis = v_num_devis[:11]+'B'
    return self.write(cr, uid, ids, {'state': 'x_approve_quotation','x_num_devis': v_num_devis}, context=context)



#def act_approve_quotation(self, cr, uid,id,default= None, context=None):
    #return self.copy_data(cr, uid, id, default, context=context)

def action_button_confirm(self, cr, uid, ids, context=None):
    assert len(ids) == 1, 'This option should only be used for a single id at a time.'
    wf_service = netsvc.LocalService('workflow')
    wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)

    # redisplay the record as a sales order
    view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
    view_id = view_ref and view_ref[1] or False,
    self.write(cr, uid, ids, {'x_num_commande': self.pool.get('ir.sequence').get(cr, uid, 'sequence.numero.commande')}, context=context)
    return {

    }   




Thanks for your help.
0
DelphineL
On 7/1/14, 7:12 PM

Hello

What are the error messages in the log ?
otherwise you can  install eclipse and debug step by step

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

1 follower(s)

Stats

Asked: 2/14/14, 8:54 AM
Seen: 908 times
Last updated: 3/16/15, 8:10 AM