Browse Source

also transfer status in invoice

pull/134/head
dev_cbssolutions 6 years ago
parent
commit
3ba2f7fa93
  1. 21
      invoice_stock_move/models/invoice_stock.py
  2. 4
      invoice_stock_move/views/invoice_stock_move_view.xml

21
invoice_stock_move/models/invoice_stock.py

@ -32,6 +32,16 @@ class InvoiceStockMove(models.Model):
@api.onchange('type','invoice_line_ids') @api.onchange('type','invoice_line_ids')
def onchange_invoice_type(self): def onchange_invoice_type(self):
if self.env.context.get('default_team_id',False) or (self._fields.get('team_id',False) and self.invoice_origin): # is a invoice from sale order
transfer_state = 'make_the_transfer_from_sale'
self.transfer_state = transfer_state
return
if self.env.context.get('default_purchase_id',False) or (self._fields.get('purchase_id',False) and self.purchase_id): # is a invoice from purchase order
transfer_state = 'make_the_transfer_from_purchase'
self.transfer_state = transfer_state
return
transfer_state = 'nothing_to_transfer' transfer_state = 'nothing_to_transfer'
for line in self.invoice_line_ids: for line in self.invoice_line_ids:
if line.product_id: if line.product_id:
@ -43,15 +53,9 @@ class InvoiceStockMove(models.Model):
if transfer_state == 'not_initiated': if transfer_state == 'not_initiated':
if self.type in ['out_invoice','out_receipt']: if self.type in ['out_invoice','out_receipt']:
domain=[('code','=','outgoing')] domain=[('code','=','outgoing')]
if self._fields.get('team_id',False) and self.team_id: # is a invoice from sale order
transfer_state = 'make_the_transfer_from_sale'
return
elif self.type in ['in_invoice','in_receipt']: elif self.type in ['in_invoice','in_receipt']:
domain=[('code','=','incoming')] domain=[('code','=','incoming')]
if self._fields.get('purchase_id',False) and self.purchase_id: # is a invoice from purchase order
transfer_state = 'make_the_transfer_from_purchase'
return
if not self.picking_type_id: if not self.picking_type_id:
type_obj = self.env['stock.picking.type'] type_obj = self.env['stock.picking.type']
company_id = self.env.context.get('company_id') or self.env.user.company_id.id company_id = self.env.context.get('company_id') or self.env.user.company_id.id
@ -67,10 +71,13 @@ class InvoiceStockMove(models.Model):
('make_the_transfer_from_purchase','make_the_transfer_from_purchase'), ('make_the_transfer_from_purchase','make_the_transfer_from_purchase'),
('make_the_transfer_from_sale','make_the_transfer_from_sale'), ('make_the_transfer_from_sale','make_the_transfer_from_sale'),
],string='Stock Transfer State',help='If the transfer form invoice was done or not',copy=False) ],string='Stock Transfer State',help='If the transfer form invoice was done or not',copy=False)
invoice_picking_id = fields.Many2one('stock.picking', string="Picking Id",copy=False)
picking_type_id = fields.Many2one('stock.picking.type', 'Picking Type', required=False, picking_type_id = fields.Many2one('stock.picking.type', 'Picking Type', required=False,
help="This will determine picking type of incoming shipment",copy=False) help="This will determine picking type of incoming shipment",copy=False)
invoice_picking_id = fields.Many2one('stock.picking', string="Picking Id",copy=False)
picking_status = fields.Selection(related='invoice_picking_id.state')
def action_stock_move(self): def action_stock_move(self):
"will be executed at the pressing of transfer button" "will be executed at the pressing of transfer button"
for order in self: # order is account.move meaning also invoice for order in self: # order is account.move meaning also invoice

4
invoice_stock_move/views/invoice_stock_move_view.xml

@ -20,8 +20,8 @@
name="action_view_picking" states="open,paid" name="action_view_picking" states="open,paid"
class="oe_stat_button" attrs="{'invisible':['|',('state','=','draft'),('transfer_state', '!=', 'transfered')]}" class="oe_stat_button" attrs="{'invisible':['|',('state','=','draft'),('transfer_state', '!=', 'transfered')]}"
icon="fa-truck"> icon="fa-truck">
<!-- <field name="transfer_state" string="Shipment" widget="statinfo"/> <field name="picking_status" string="Transfer Status" widget="statinfo"/>
--> </button> </button>
</div> </div>
</xpath> </xpath>
</field> </field>

Loading…
Cancel
Save