[9.0][FIX] rma:

* fix assignment of moves.
* default qty in rma lines.
* remove account dependency.
* test and flake8 fixes.
This commit is contained in:
lreficent
2017-08-02 17:05:58 +02:00
committed by Florian da Costa
parent 7fdcf5e1e2
commit 0d4c438e26
12 changed files with 121 additions and 145 deletions

View File

@@ -10,28 +10,29 @@ class StockPicking(models.Model):
@api.multi
def action_assign(self):
"""When you try to bring back a product from a customer location,
it may happen that there is no quants available to perform the
picking."""
res = super(StockPicking, self).action_assign()
for picking in self:
for move in picking.move_lines:
if len(move.rma_line_id):
if move.state in ('confirmed', 'waiting', 'assigned') \
and move.location_id.usage in (
'supplier', 'customer'):
move.force_assign()
return super(StockPicking, self).action_assign()
if (move.rma_line_id and move.state == 'confirmed' and
move.location_id.usage == 'customer'):
move.force_assign()
return res
class StockMove(models.Model):
_inherit = "stock.move"
rma_line_id = fields.Many2one('rma.order.line', string='RMA',
rma_line_id = fields.Many2one('rma.order.line', string='RMA line',
ondelete='restrict')
@api.model
def create(self, vals):
if vals.get('procurement_id', False):
if vals.get('procurement_id'):
procurement = self.env['procurement.order'].browse(
vals['procurement_id'])
if procurement.rma_line_id and procurement.rma_line_id.id:
if procurement.rma_line_id:
vals['rma_line_id'] = procurement.rma_line_id.id
return super(StockMove, self).create(vals)