def claim_line_create(self, cr, uid, ids, context=None): if context is None: context = {} create_ids = [] sales = set() for line in self.browse(cr, SUPERUSER_ID, ids, context=context): vals = self._prepare_order_line_claim_line(cr, uid, line, context=context) if vals: inv_id = self.pool.get('claim.line').create(cr, SUPERUSER_ID, vals, context=context) self.write(cr, SUPERUSER_ID, [line.id], {'claim_lines': [(4, inv_id)]}, context=context) sales.add(line.order_id.id) create_ids.append(inv_id) # Trigger workflow events for sale_id in sales: workflow.trg_write(uid, 'sale.order', sale_id, cr) return create_ids
def invoice_line_create(self, cr, uid, ids, context=None): if context is None: context = {} create_ids = [] sales = set() for line in self.browse(cr, uid, ids, context=context): vals = self._prepare_order_line_invoice_line(cr, uid, line, False, context) ids = [] if vals: if line.replacement: context['no_control_qty'] = True orig = self._get_orig_line(cr, uid, line, context) context.pop('', False) ids.append(orig.id) else: ids.append(line.id) inv_id = self.pool.get('account.invoice.line').create(cr, uid, vals, context=context) self.write(cr, uid, ids, {'invoice_lines': [(4, inv_id)]}, context=context) sales.add(line.order_id.id) create_ids.append(inv_id) # Trigger workflow events for sale_id in sales: workflow.trg_write(uid, 'sale.order', sale_id, cr) return create_ids
def do_transfer(self, cr, uid, picking_ids, context=None): res = super(stock_picking, self).do_transfer(cr, uid, picking_ids, context) for picking in self.browse(cr, uid, picking_ids, context): if picking.sale_id and picking.sale_id.sample: workflow.trg_write(uid, 'sale.order', picking.sale_id.id, cr) return res
def button_done(self): ''' @param self: object pointer ''' #~ lines = [folio_line.order_line_id for folio_line in self] #~ lines.button_done() self.write({'state': 'done'}) for folio_line in self: workflow.trg_write(self._uid, 'sale.order', folio_line.order_line_id.order_id.id, self._cr) return True
def cancel_quantity(self): self.ensure_one() for line in self.line_ids: if line.cancelled_qty > line.product_qty: raise exceptions.Warning( _("""Quantity to cancel is greater than available quantity""")) # To allow to add some quantity already cancelled if line.cancelled_qty < 0 and\ abs(line.cancelled_qty) > line.so_line_id.cancelled_qty: raise exceptions.Warning( _("""Quantity to cancel is greater than quantity already cancelled""")) line.so_line_id.cancelled_qty += line.cancelled_qty workflow.trg_write(self._uid, 'sale.order', line.so_line_id.order_id.id, self._cr)
def cancel_quantity(self): self.ensure_one() for line in self.line_ids: if line.cancelled_qty > line.product_qty: raise exceptions.Warning( _("""Quantity to cancel is greater than available quantity""")) # To allow to add some quantity already cancelled if line.cancelled_qty < 0 and\ abs(line.cancelled_qty) > line.po_line_id.cancelled_qty: raise exceptions.Warning( _("""Quantity to cancel is greater than quantity already cancelled""")) line.po_line_id.cancelled_qty += line.cancelled_qty workflow.trg_write(self._uid, 'purchase.order', line.po_line_id.order_id.id, self._cr)
def invoice_line_create(self, cr, uid, ids, context=None): if context is None: context = {} create_ids = [] sales = set() for line in self.browse(cr, uid, ids, context=context): vals = self._prepare_order_line_invoice_line(cr, uid, line, False, context) if vals: vals['account_analytic_id'] = line.account_analytic_id.id or False inv_id = self.pool.get('account.invoice.line').create(cr, uid, vals, context=context) self.write(cr, uid, [line.id], {'invoice_lines': [(4, inv_id)]}, context=context) sales.add(line.order_id.id) create_ids.append(inv_id) # Trigger workflow events for sale_id in sales: workflow.trg_write(uid, 'sale.order', sale_id, cr) return create_ids
def invoice_validate(self, cr, uid, ids, context=None): invoice_id = self.browse(cr, uid, ids, context=context) if invoice_id.state == 'open': return True res = super(dym_account_invoice, self).invoice_validate(cr, uid, ids, context=context) if invoice_id.type == "in_invoice" and invoice_id.tipe == 'purchase' and invoice_id.state == 'open': product_over_qty = [] for invoice_line in invoice_id.invoice_line : if invoice_line.purchase_line_id : purchase_line_id = invoice_line.purchase_line_id current_invoiced = purchase_line_id.qty_invoiced a = purchase_line_id.id obj_inv_line = self.pool.get('account.invoice.line') inv_line_ids = obj_inv_line.search(cr, uid, [('purchase_line_id', '=', a), ('invoice_id.state', '=', 'is_refund')]) for line in inv_line_ids: inv_line = obj_inv_line.browse(cr, uid, line) invoice_refund += inv_line.quantity if invoice_refund: new_invoiced = invoice_line.quantity + current_invoiced - invoice_refund else : new_invoiced = invoice_line.quantity + current_invoiced if new_invoiced > purchase_line_id.product_qty : raise Warning(("Quantity product '%s' melebihi quantity PO !\nQty invoice: '%s', Qty PO: '%s'" %(purchase_line_id.product_id.name, int(new_invoiced), int(purchase_line_id.product_qty)))) elif new_invoiced < purchase_line_id.product_qty : purchase_line_id.write({'qty_invoiced':new_invoiced, 'invoiced':False}) else : purchase_line_id.write({'qty_invoiced':new_invoiced, 'invoiced':True}) purchase_order_obj = self.pool.get('purchase.order') po_ids = purchase_order_obj.search(cr, uid, [('invoice_ids', 'in', ids)], context=context) if not purchase_order_obj.check_access_rights(cr, uid, 'read', raise_exception=False): user_id = SUPERUSER_ID else: user_id = uid for order in purchase_order_obj.browse(cr, uid, po_ids, context=context): for line in order.order_line: if line.qty_invoiced < line.product_qty and line.invoiced == True: line.write({'invoiced':False}) workflow.trg_write(user_id, 'purchase.order', order.id, cr) return res
def action_reset(self, cr, uid, ids, context=None): for instance in self.browse(cr, uid, ids, context=context): if instance.state == 'active' and len(instance.item_ids) == 1 \ and instance.item_ids[0].state == 'running' and not instance.trigger_ids: self.pool['workflow.transition'].unlink( cr, uid, [t.id for t in instance.transition_ids], context=context) self.pool['workflow.workitem'].write(cr, uid, [instance.item_ids[0].id], {'state': 'complete'}, context=context) from openerp import workflow workflow.trg_write(uid, instance.res_type, instance.res_id, cr, context=context) return True
def invoice_line_create(self): create_ids = [] sales = set() for line in self: vals = self._prepare_order_line_invoice_line(line, False) ids = self.env['sale.order.line'] if vals: if line.replacement: orig = line.with_context(no_control_qty=True)._get_orig_line() ids += orig else: ids += line inv = self.env['account.invoice.line'].create(vals) ids.write({'invoice_lines': [(4, inv.id)]}) sales.add(line.order_id.id) create_ids.append(inv.id) # Trigger workflow events for sale_id in sales: workflow.trg_write(self.env.user.id, 'sale.order', sale_id, self.env.cr) return create_ids
def _validate_subflows(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids): if task.procurement_id: workflow.trg_write(uid, 'procurement.order', task.procurement_id.id, cr)