python - How to separate stock picking in from out in odoo 8 -


in openerp 7 stock_picking separated in 2 items, stock_picking_in , stock_picking_out, created 1 item containing both , there's field containing type (in or out). want have normal view "in" items , totally custom view "out". possible , how? thanks.

my picking.py inherit stock.picking , add fields. want picking_in_view use stock.picking default display form view , tree view , want change display picking_out_view. problem when change display in picking_out_view change in picking_in_view because changes model.

and biggest problem need change many many field stock.move out items if need modify model , in , out.

is there way it?

move.py

# -*- coding: utf-8 -*-  openerp import models, fields, api, tools openerp.exceptions import validationerror   class stockmove(models.model):     """     ajout de champs dans la ligne de commande, et quelques fonctions     telles que unpack     """     _inherit = "stock.move"      # le code du produit à afficher     product_code = fields.char(string="product", store=true, related="product_id.default_code")     # le lien vers la ligne d'achat sale.order.line     sale_line_id = fields.many2one(string="saleorderline", store=true, related="procurement_id.sale_line_id")     # le colis associé à la commande     stock_quant_package = fields.many2one('stock.quant.package', string='pack')      # sert à savoir si on affiche l'icône rouge pour déballer un colis     show_unpack = fields.boolean(store=false, compute='compute_show_unpack')     # sert à savoir si on affiche l'icône d'impression validée     is_printed = fields.boolean(store=false, compute='compute_printed')     # pour colorer les lignes, condition     statut_ok = fields.boolean(default=false, store=false, compute="compute_statut_ok")      # le statut de la commande     statut_id = fields.many2one('sale.statut', string='statut', default=lambda self: self._default_statut_id())     date_emballage = fields.datetime("date d'emballage")      # champs non enregistrés en bd, utilisés pour l'affichage     metal = fields.many2one('product.finition',string="metal", store=false, related="procurement_id.sale_line_id.metal")     bois1 = fields.many2one('product.finition',string="bois 1", store=false, related="procurement_id.sale_line_id.bois1")     bois2 = fields.many2one('product.finition',string="bois 2", store=false, related="procurement_id.sale_line_id.bois2")     verre = fields.many2one('product.finition',string="verre", store=false, related="procurement_id.sale_line_id.verre")     tissu = fields.many2one('product.finition',string="tissu", store=false, related="procurement_id.sale_line_id.tissu")     patte = fields.many2one('product.finition',string="patte", store=false, related="procurement_id.sale_line_id.patte")     config = fields.char(string="config", store=false, size=64, related="procurement_id.sale_line_id.config")     poignee = fields.many2one('product.finition',string="poignee", store=false, related="procurement_id.sale_line_id.poignee")      # le prix d'une ligne de commande, calculé     move_price = fields.float(string="prix", store=false, compute="compute_move_price")      # pour differencier les formulaires     is_picking_out = fields.boolean(store=false, compute="compute_is_picking_out")      ... 

picking.py

# -*- coding: utf-8 -*-  openerp import models, fields, api, tools   class stockpicking(models.model):     _inherit = "stock.picking"      # le statut     statut_id = fields.many2one("sale.statut", string="statut")      # erreur inconnue sur l'inexistence de ce champ; à laisser     stock_journal_id = fields.integer()      carrier_id = fields.many2one("stock.carrier", compute="_carrier_info")     num_compte_transport = fields.char(string="numéro de compte ups", compute="_carrier_info")     @api.multi     def _carrier_info(self):         line in self:             line.carrier_id = self.sale_id.carrier_transport             line.num_compte_transport = self.sale_id.num_compte_facture 

picking_in_view.xml

<?xml version="1.0" encoding="utf-8"?> <openerp>     <data>          <!-- on cache un attribut de la liste des bons de livraison -->         <record id="stock_picking_tree_view_cr" model="ir.ui.view">             <field name="name">stock.picking.tree.inherit.cr</field>             <field name="model">stock.picking</field>             <field name="priority" eval="2"/>             <field name="inherit_id" ref="stock.vpicktree"/>             <field name="arch" type="xml">                  <xpath expr="//tree/field[@name='location_dest_id']" position="attributes">                     <attribute name="invisible">1</attribute>                 </xpath>              </field>         </record>          <!-- les boutons de modification de la commande de base par odoo dans le formulaire -->         <!-- des bons de livraison -->         <record id="stock_picking_form_view_cr" model="ir.ui.view">             <field name="name">stock.picking.form.inherit.cr</field>             <field name="model">stock.picking</field>             <field name="priority" eval="2"/>             <field name="inherit_id" ref="stock.view_picking_form"/>             <field name="arch" type="xml">                  <xpath expr="//form/header/button[@name='action_assign']" position="attributes">                     <attribute name="invisible">0</attribute>                 </xpath>                 <xpath expr="//form/header/button[@name='force_assign']" position="attributes">                     <attribute name="invisible">0</attribute>                 </xpath>                 <xpath expr="//form/header/button[@name='action_cancel']" position="attributes">                     <attribute name="invisible">0</attribute>                 </xpath>              </field>         </record>          <!-- - - - - - - - - - - - - actions - - - - - - - - - - - - -->          <!-- l'action du bouton dans le menu lateral -->         <record id="picking_in_action_createch" model="ir.actions.act_window">             <field name="name">bons de réception</field>             <field name="res_model">stock.picking</field>             <field name="view_type">form</field>             <field name="view_mode">tree,form</field>             <field name="domain">                 [('picking_type_id','=',1)]             </field>         </record>          <!-- - - - - - - - - - - - - menus - - - - - - - - - - - - -->          <!-- le premier bouton dans la barre laterale -->         <menuitem id="picking_orders_menu" name="bons de réception"                   sequence="0"                   parent="warehouse_mgt_cr"                   action="picking_in_action_createch"/>     </data> </openerp> 

picking_out_view.xml

<?xml version="1.0" encoding="utf-8"?> <openerp>     <data>          <!-- liste des colis -->         <record id="stock_quant_package_tree_view" model="ir.ui.view">             <field name="name">stock.quant.package.tree.cr</field>             <field name="model">stock.quant.package</field>             <field name="priority" eval="2"/>             <field name="arch" type="xml">                  <tree string="paquets">                     <field name="name"/>                     <field name="order_name"/>                     <field name="item"/>                     <field name="owner_name"/>                     <field name="create_date"/>                     <field name="prix" sum="total amount"/>                 </tree>              </field>         </record>          <!-- on cache un attribut de la liste des bons de livraison -->         <record id="stock_picking_tree_view_cr" model="ir.ui.view">             <field name="name">stock.picking.tree.inherit.cr</field>             <field name="model">stock.picking</field>             <field name="priority" eval="2"/>             <field name="inherit_id" ref="stock.vpicktree"/>             <field name="arch" type="xml">                  <xpath expr="//tree/field[@name='location_dest_id']" position="attributes">                     <attribute name="invisible">1</attribute>                 </xpath>              </field>         </record>          <!-- les boutons de modification de la commande de base par odoo dans le formulaire -->         <!-- des bons de livraison -->         <record id="stock_picking_form_view_cr" model="ir.ui.view">             <field name="name">stock.picking.form.inherit.cr</field>             <field name="model">stock.picking</field>             <field name="priority" eval="2"/>             <field name="inherit_id" ref="stock.view_picking_form"/>             <field name="arch" type="xml">                  <xpath expr="//form/header/button[@name='action_assign']" position="attributes">                     <attribute name="invisible">1</attribute>                 </xpath>                 <xpath expr="//form/header/button[@name='force_assign']" position="attributes">                     <attribute name="invisible">1</attribute>                 </xpath>                 <xpath expr="//form/header/button[@name='action_cancel']" position="attributes">                     <attribute name="invisible">1</attribute>                 </xpath>              </field>         </record>          <!-- - - - - - - - - - - - - actions - - - - - - - - - - - - -->          <!-- l'action du bouton dans le menu lateral -->         <record id="picking_action_createch" model="ir.actions.act_window">             <field name="name">bons de livraison</field>             <field name="res_model">stock.picking</field>             <field name="view_type">form</field>             <field name="view_mode">tree,form</field>             <field name="domain">                 [('picking_type_id','=',2)]             </field>             <field name="context">{"search_default_filter_a_emballer":1}</field>         </record>          <!-- un autre bouton dans la barre laterale. sert de test actuellement -->         <record id="stock_quant_package_action_createch" model="ir.actions.act_window">             <field name="name">colis</field>             <field name="res_model">stock.quant.package</field>             <field name="view_type">form</field>             <field name="view_mode">tree,form</field>         </record>           <!-- - - - - - - - - - - - - menus - - - - - - - - - - - - -->          <!-- le titre dans la barre laterale -->         <menuitem id="warehouse_mgt_cr" name="warehouse management"                   sequence="0"                   parent="stock.menu_stock_root"/>          <!-- le premier bouton dans la barre laterale -->         <menuitem id="delivery_orders_menu" name="bons de livraison"                   sequence="1"                   parent="warehouse_mgt_cr"                   action="picking_action_createch"/>         <menuitem id="quant_package_colis_menu" name="colis"                   sequence="3"                   parent="warehouse_mgt_cr"                   action="stock_quant_package_action_createch"/>      </data> </openerp> 

one way achieve use attrs , based on picking type hide or show fields, if want make minor changes, whole document not best solution.

second way create different views them if using different menuitems opening objects, on action attached on menuitem can specify form , tree views id, example:

    <record id="action_id" model="ir.actions.act_window">         <field name="name">action</field>         <field name="res_model">model.name</field>         <field name="type">ir.actions.act_window</field>         <field name="view_type">form</field>          <field name="view_mode">tree,form</field>     </record>      <record model="ir.actions.act_window.view" id="action_id_tree">         <field name="sequence" eval="5"/>         <field name="view_mode">tree_sent_grievances</field>         <field name="view_id" ref="tree_view_id"/>         <field name="act_window_id" ref="action_id"/>     </record>      <record model="ir.actions.act_window.view" id="action_id_form">         <field name="sequence" eval="5"/>         <field name="view_mode">form</field>         <field name="view_id" ref="form_view_id"/>         <field name="act_window_id" ref="action_id"/>     </record> 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -