mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
@@ -10,8 +10,8 @@ class RmaAddStockMove(models.TransientModel):
|
||||
_description = 'Wizard to add rma lines from pickings'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(RmaAddStockMove, self).default_get(fields)
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaAddStockMove, self).default_get(fields_list)
|
||||
rma_obj = self.env['rma.order']
|
||||
rma_id = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -26,13 +26,13 @@ class RmaMakePicking(models.TransientModel):
|
||||
return values
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
"""Default values for wizard, if there is more than one supplier on
|
||||
lines the supplier field is empty otherwise is the unique line
|
||||
supplier.
|
||||
"""
|
||||
context = self._context.copy()
|
||||
res = super(RmaMakePicking, self).default_get(fields)
|
||||
res = super(RmaMakePicking, self).default_get(fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -47,9 +47,9 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
||||
}
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaLineMakeSupplierRma, self).default_get(
|
||||
fields)
|
||||
fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -10,8 +10,8 @@ class RmaAddInvoice(models.TransientModel):
|
||||
_description = 'Wizard to add rma lines'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(RmaAddInvoice, self).default_get(fields)
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaAddInvoice, self).default_get(fields_list)
|
||||
rma_obj = self.env['rma.order']
|
||||
rma_id = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -32,13 +32,13 @@ class RmaRefund(models.TransientModel):
|
||||
return values
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
"""Default values for wizard, if there is more than one supplier on
|
||||
lines the supplier field is empty otherwise is the unique line
|
||||
supplier.
|
||||
"""
|
||||
context = self._context.copy()
|
||||
res = super(RmaRefund, self).default_get(fields)
|
||||
res = super(RmaRefund, self).default_get(fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -24,13 +24,13 @@ class RmaMakePicking(models.TransientModel):
|
||||
return values
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
"""Default values for wizard, if there is more than one supplier on
|
||||
lines the supplier field is empty otherwise is the unique line
|
||||
supplier.
|
||||
"""
|
||||
context = self._context.copy()
|
||||
res = super(RmaMakePicking, self).default_get(fields)
|
||||
res = super(RmaMakePicking, self).default_get(fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
@@ -51,8 +51,8 @@ class RmaMakePicking(models.TransientModel):
|
||||
|
||||
types = self.env['stock.picking.type'].search(
|
||||
[('code', '=', 'internal'),
|
||||
('warehouse_id.company_id', '=',
|
||||
line.in_warehouse_id.id)])[:1]
|
||||
('warehouse_id', 'in',
|
||||
lines.mapped('in_warehouse_id').ids)])[:1]
|
||||
if not types:
|
||||
raise ValidationError(_('Please define an internal picking type '
|
||||
'for this warehouse'))
|
||||
|
||||
@@ -10,8 +10,8 @@ class RmaAddPurchase(models.TransientModel):
|
||||
_description = 'Wizard to add rma lines'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(RmaAddPurchase, self).default_get(fields)
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaAddPurchase, self).default_get(fields_list)
|
||||
rma_obj = self.env['rma.order']
|
||||
rma_id = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -34,9 +34,9 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
}
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaLineMakePurchaseOrder, self).default_get(
|
||||
fields)
|
||||
fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
@@ -109,16 +109,10 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
po_line_obj.create(po_line_data)
|
||||
res.append(purchase.id)
|
||||
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str, res))+"])]",
|
||||
'name': _('Request for Quotation'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'purchase.order',
|
||||
'view_id': False,
|
||||
'context': False,
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
action = self.env.ref('purchase.purchase_rfq')
|
||||
result = action.read()[0]
|
||||
result['domain'] = "[('id','in', ["+','.join(map(str, res))+"])]"
|
||||
return result
|
||||
|
||||
|
||||
class RmaLineMakePurchaseOrderItem(models.TransientModel):
|
||||
|
||||
@@ -37,9 +37,9 @@ class RmaLineMakeRepair(models.TransientModel):
|
||||
}
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaLineMakeRepair, self).default_get(
|
||||
fields)
|
||||
fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -10,8 +10,8 @@ class RmaAddSale(models.TransientModel):
|
||||
_description = 'Wizard to add rma lines from SO lines'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(RmaAddSale, self).default_get(fields)
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaAddSale, self).default_get(fields_list)
|
||||
rma_obj = self.env['rma.order']
|
||||
rma_id = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
|
||||
@@ -23,7 +23,6 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
||||
def _prepare_item(self, line):
|
||||
return {
|
||||
'line_id': line.id,
|
||||
'rma_line_id': line.id,
|
||||
'product_id': line.product_id.id,
|
||||
'name': line.product_id.name,
|
||||
'product_qty': line.qty_to_sell,
|
||||
@@ -33,9 +32,9 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
||||
}
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaLineMakeSaleOrder, self).default_get(
|
||||
fields)
|
||||
fields_list)
|
||||
rma_line_obj = self.env['rma.order.line']
|
||||
rma_line_ids = self.env.context['active_ids'] or []
|
||||
active_model = self.env.context['active_model']
|
||||
@@ -59,13 +58,13 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _prepare_sale_order(self, out_warehouse, company):
|
||||
def _prepare_sale_order(self, out_warehouse, company, item):
|
||||
if not self.partner_id:
|
||||
raise exceptions.Warning(
|
||||
_('Enter a customer.'))
|
||||
customer = self.partner_id
|
||||
data = {
|
||||
'origin': '',
|
||||
'origin': item.line_id.name,
|
||||
'partner_id': customer.id,
|
||||
'warehouse_id': out_warehouse.id,
|
||||
'company_id': company.id,
|
||||
@@ -103,24 +102,20 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
||||
if self.sale_order_id:
|
||||
sale = self.sale_order_id
|
||||
if not sale:
|
||||
po_data = self._prepare_sale_order(line.out_warehouse_id,
|
||||
line.company_id)
|
||||
po_data = self._prepare_sale_order(
|
||||
line.out_warehouse_id,
|
||||
line.company_id,
|
||||
item)
|
||||
sale = sale_obj.create(po_data)
|
||||
|
||||
so_line_data = self._prepare_sale_order_line(sale, item)
|
||||
so_line_obj.create(so_line_data)
|
||||
res.append(sale.id)
|
||||
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str, res))+"])]",
|
||||
'name': _('Quotations'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'sale.order',
|
||||
'view_id': False,
|
||||
'context': False,
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
action = self.env.ref('sale.action_orders')
|
||||
result = action.read()[0]
|
||||
result['domain'] = "[('id','in', ["+','.join(map(str, res))+"])]"
|
||||
return result
|
||||
|
||||
|
||||
class RmaLineMakeSaleOrderItem(models.TransientModel):
|
||||
|
||||
Reference in New Issue
Block a user