[IMP] several subtype fixes
bzr revid: fp@tinyerp.com-20121218220617-d6ebdlkf1facw4x8
This commit is contained in:
parent
8e0c7f9781
commit
41f7f27881
|
@ -184,7 +184,12 @@ class account_invoice(osv.osv):
|
|||
_inherit = ['mail.thread']
|
||||
_description = 'Invoice'
|
||||
_order = "id desc"
|
||||
|
||||
_track = {
|
||||
'state': {
|
||||
'account.mt_invoice_paid': lambda self, cr, uid, obj, ctx=None: obj.state == 'paid' and obj.type in ('out_invoice','out_refund'),
|
||||
'account.mt_invoice_validated': lambda self, cr, uid, obj, ctx=None: obj.state == 'open' and obj.type in ('out_invoice','out_refund'),
|
||||
},
|
||||
}
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice.", readonly=True, states={'draft':[('readonly',False)]}),
|
||||
|
@ -221,7 +226,7 @@ class account_invoice(osv.osv):
|
|||
'date_due': fields.date('Due Date', readonly=True, states={'draft':[('readonly',False)]}, select=True,
|
||||
help="If you use payment terms, the due date will be computed automatically at the generation "\
|
||||
"of accounting entries. The payment term may compute several due dates, for example 50% now and 50% in one month, but if you want to force a due date, make sure that the payment term is not set on the invoice. If you keep the payment term and the due date empty, it means direct payment."),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}, track_visibility=2),
|
||||
'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]},
|
||||
help="If you use payment terms, the due date will be computed automatically at the generation "\
|
||||
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "\
|
||||
|
@ -233,7 +238,7 @@ class account_invoice(osv.osv):
|
|||
'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
|
||||
'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, select=1, ondelete='restrict', help="Link to the automatically generated Journal Items."),
|
||||
'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Untaxed',
|
||||
'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Untaxed', track_visibility=2,
|
||||
store={
|
||||
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
|
||||
'account.invoice.tax': (_get_invoice_tax, None, 20),
|
||||
|
@ -254,7 +259,7 @@ class account_invoice(osv.osv):
|
|||
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20),
|
||||
},
|
||||
multi='all'),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}, track_visibility=2),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'check_total': fields.float('Verification Total', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}),
|
||||
|
@ -278,7 +283,7 @@ class account_invoice(osv.osv):
|
|||
help="Remaining amount due."),
|
||||
'payment_ids': fields.function(_compute_lines, relation='account.move.line', type="many2many", string='Payments'),
|
||||
'move_name': fields.char('Journal Entry', size=64, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', readonly=True, tracked=True, states={'draft':[('readonly',False)]}),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', readonly=True, tracked=True, states={'draft':[('readonly',False)]}, track_visibility=1),
|
||||
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position', readonly=True, states={'draft':[('readonly',False)]})
|
||||
}
|
||||
_defaults = {
|
||||
|
@ -437,7 +442,6 @@ class account_invoice(osv.osv):
|
|||
if context is None:
|
||||
context = {}
|
||||
self.write(cr, uid, ids, {'state':'paid'}, context=context)
|
||||
self.confirm_paid_send_note(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
@ -1106,7 +1110,6 @@ class account_invoice(osv.osv):
|
|||
# will be automatically deleted too
|
||||
account_move_obj.unlink(cr, uid, move_ids, context=context)
|
||||
self._log_event(cr, uid, ids, -1.0, 'Cancel Invoice')
|
||||
self.invoice_cancel_send_note(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
###################
|
||||
|
@ -1333,17 +1336,6 @@ class account_invoice(osv.osv):
|
|||
}
|
||||
return type_dict.get(type, 'Invoice')
|
||||
|
||||
def confirm_paid_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("%s <b>paid</b>.") % (self._get_document_type(obj.type)),
|
||||
subtype="account.mt_invoice_paid", context=context)
|
||||
|
||||
def invoice_cancel_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("%s <b>cancelled</b>.") % (self._get_document_type(obj.type)),
|
||||
context=context)
|
||||
|
||||
|
||||
class account_invoice_line(osv.osv):
|
||||
|
||||
def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict):
|
||||
|
|
|
@ -308,23 +308,6 @@ class account_analytic_account(osv.osv):
|
|||
account_ids = self.search(cr, uid, args, limit=limit, context=context)
|
||||
return self.name_get(cr, uid, account_ids, context=context)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
contract = super(account_analytic_account, self).create(cr, uid, vals, context=context)
|
||||
if contract:
|
||||
self.create_send_note(cr, uid, [contract], context=context)
|
||||
return contract
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Contract <b>created</b>.")
|
||||
if obj.partner_id:
|
||||
message = _("Contract for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name,)
|
||||
self.message_post(cr, uid, [obj.id], body=message,
|
||||
context=context)
|
||||
|
||||
account_analytic_account()
|
||||
|
||||
|
||||
class account_analytic_line(osv.osv):
|
||||
_name = 'account.analytic.line'
|
||||
_description = 'Analytic Line'
|
||||
|
|
|
@ -104,8 +104,8 @@ class crm_claim(base_stage, osv.osv):
|
|||
'email_cc': fields.text('Watchers Emails', size=252, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
|
||||
'email_from': fields.char('Email', size=128, help="Destination email for email gateway."),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'stage_id': fields.many2one ('crm.claim.stage', 'Stage',
|
||||
domain="['&',('fold', '=', False),'|', ('section_ids', '=', section_id), ('case_default', '=', True)]"),
|
||||
'stage_id': fields.many2one ('crm.claim.stage', 'Stage', track_visibility=1,
|
||||
domain="['&',('fold', '=', False),'|', ('section_ids', '=', section_id), ('case_default', '=', True)]"),
|
||||
'cause': fields.text('Root Cause'),
|
||||
'state': fields.related('stage_id', 'state', type="selection", store=True,
|
||||
selection=crm.AVAILABLE_STATES, string="Status", readonly=True,
|
||||
|
@ -158,18 +158,13 @@ class crm_claim(base_stage, osv.osv):
|
|||
return stage_ids[0]
|
||||
return False
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(crm_claim, self).create(cr, uid, vals, context)
|
||||
self.create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def case_refuse(self, cr, uid, ids, context=None):
|
||||
""" Mark the case as refused: state=done and case_refused=True """
|
||||
for lead in self.browse(cr, uid, ids):
|
||||
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, ['&', ('state', '=', 'done'), ('case_refused', '=', True)], context=context)
|
||||
if stage_id:
|
||||
self.case_set(cr, uid, [lead.id], values_to_update={}, new_stage_id=stage_id, context=context)
|
||||
return self.case_refuse_send_note(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, part, email=False):
|
||||
"""This function returns value of partner address based on partner
|
||||
|
@ -231,28 +226,6 @@ class crm_claim(base_stage, osv.osv):
|
|||
|
||||
return super(crm_claim,self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
|
||||
|
||||
# ---------------------------------------------------
|
||||
# OpenChatter methods and notifications
|
||||
# ---------------------------------------------------
|
||||
|
||||
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
|
||||
""" Override of default prefix for notifications. """
|
||||
return 'Claim'
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
msg = _('Claim has been <b>created</b>.')
|
||||
return self.message_post(cr, uid, ids, body=msg, context=context)
|
||||
|
||||
def case_refuse_send_note(self, cr, uid, ids, context=None):
|
||||
msg = _('Claim has been <b>refused</b>.')
|
||||
return self.message_post(cr, uid, ids, body=msg, context=context)
|
||||
|
||||
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
|
||||
""" Override of the (void) default notification method. """
|
||||
stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
|
||||
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
|
||||
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
_columns = {
|
||||
|
|
|
@ -89,11 +89,6 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
|
|||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(crm_helpdesk, self).create(cr, uid, vals, context)
|
||||
self.create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
# -------------------------------------------------------
|
||||
# Mail gateway
|
||||
# -------------------------------------------------------
|
||||
|
@ -140,17 +135,4 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
|
|||
|
||||
return super(crm_helpdesk,self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
|
||||
|
||||
# ---------------------------------------------------
|
||||
# OpenChatter
|
||||
# ---------------------------------------------------
|
||||
|
||||
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
|
||||
""" override of default base_state method. """
|
||||
return 'Case'
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
msg = _('Case has been <b>created</b>.')
|
||||
self.message_post(cr, uid, ids, body=msg, context=context)
|
||||
return True
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -375,19 +375,6 @@ class mrp_bom(osv.osv):
|
|||
default.update(name=_("%s (copy)") % (bom_data['name']), bom_id=False)
|
||||
return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(mrp_bom, self).create(cr, uid, vals, context=context)
|
||||
self.create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
prod_obj = self.pool.get('product.product')
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
for prod in prod_obj.browse(cr, uid, [obj.product_id], context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("Bill of Material has been <b>created</b> for <em>%s</em> product.") % (prod.id.name_template), context=context)
|
||||
return True
|
||||
|
||||
mrp_bom()
|
||||
|
||||
def rounding(f, r):
|
||||
import math
|
||||
|
@ -1010,7 +997,6 @@ class mrp_production(osv.osv):
|
|||
|
||||
wf_service.trg_validate(uid, 'stock.picking', shipment_id, 'button_confirm', cr)
|
||||
production.write({'state':'confirmed'}, context=context)
|
||||
self.action_confirm_send_note(cr, uid, [production.id], context=context)
|
||||
return shipment_id
|
||||
|
||||
def force_production(self, cr, uid, ids, *args):
|
||||
|
@ -1022,22 +1008,6 @@ class mrp_production(osv.osv):
|
|||
pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
|
||||
return True
|
||||
|
||||
# ---------------------------------------------------
|
||||
# OpenChatter methods and notifications
|
||||
# ---------------------------------------------------
|
||||
|
||||
def action_confirm_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# convert it to the user TZ and re-render it with %Z to add the timezone
|
||||
obj_datetime = fields.DT.datetime.strptime(obj.date_planned, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
obj_date_str = fields.datetime.context_timestamp(cr, uid, obj_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
|
||||
message = _("Manufacturing order has been <b>confirmed</b> and is <b>scheduled</b> for the <em>%s</em>.") % (obj_date_str)
|
||||
self.message_post(cr, uid, [obj.id], body=message, context=context)
|
||||
return True
|
||||
|
||||
|
||||
mrp_production()
|
||||
|
||||
class mrp_production_workcenter_line(osv.osv):
|
||||
_name = 'mrp.production.workcenter.line'
|
||||
|
@ -1059,7 +1029,6 @@ class mrp_production_workcenter_line(osv.osv):
|
|||
'hour': lambda *a: 0,
|
||||
'cycle': lambda *a: 0,
|
||||
}
|
||||
mrp_production_workcenter_line()
|
||||
|
||||
class mrp_production_product_line(osv.osv):
|
||||
_name = 'mrp.production.product.line'
|
||||
|
@ -1073,7 +1042,6 @@ class mrp_production_product_line(osv.osv):
|
|||
'product_uos': fields.many2one('product.uom', 'Product UOS'),
|
||||
'production_id': fields.many2one('mrp.production', 'Production Order', select=True),
|
||||
}
|
||||
mrp_production_product_line()
|
||||
|
||||
class product_product(osv.osv):
|
||||
_inherit = "product.product"
|
||||
|
|
|
@ -112,7 +112,7 @@ class procurement_order(osv.osv):
|
|||
('running','Running'),
|
||||
('ready','Ready'),
|
||||
('done','Done'),
|
||||
('waiting','Waiting')], 'Status', required=True,
|
||||
('waiting','Waiting')], 'Status', required=True, track_visibility=1,
|
||||
help='When a procurement is created the status is set to \'Draft\'.\n If the procurement is confirmed, the status is set to \'Confirmed\'.\
|
||||
\nAfter confirming the status is set to \'Running\'.\n If any exception arises in the order then the status is set to \'Exception\'.\n Once the exception is removed the status becomes \'Ready\'.\n It is in \'Waiting\'. status when the procurement is waiting for another one to finish.'),
|
||||
'note': fields.text('Note'),
|
||||
|
@ -329,7 +329,6 @@ class procurement_order(osv.osv):
|
|||
move_obj.action_confirm(cr, uid, [id], context=context)
|
||||
self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
|
||||
self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
|
||||
self.confirm_send_note(cr, uid, ids, context)
|
||||
return True
|
||||
|
||||
def action_move_assigned(self, cr, uid, ids, context=None):
|
||||
|
@ -414,7 +413,6 @@ class procurement_order(osv.osv):
|
|||
if len(to_assign):
|
||||
move_obj.write(cr, uid, to_assign, {'state': 'assigned'})
|
||||
self.write(cr, uid, ids, {'state': 'cancel'})
|
||||
self.cancel_send_note(cr, uid, ids, context=None)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
wf_service.trg_trigger(uid, 'procurement.order', id, cr)
|
||||
|
@ -451,38 +449,13 @@ class procurement_order(osv.osv):
|
|||
if procurement.close_move and (procurement.move_id.state <> 'done'):
|
||||
move_obj.action_done(cr, uid, [procurement.move_id.id])
|
||||
res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
|
||||
self.done_send_note(cr, uid, ids, context=None)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
wf_service.trg_trigger(uid, 'procurement.order', id, cr)
|
||||
return res
|
||||
|
||||
# ----------------------------------------
|
||||
# OpenChatter methods and notifications
|
||||
# ----------------------------------------
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(procurement_order, self).create(cr, uid, vals, context)
|
||||
self.create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Procurement <b>created</b>."), context=context)
|
||||
|
||||
def confirm_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Procurement <b>confirmed</b>."), context=context)
|
||||
|
||||
def cancel_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Procurement <b>cancelled</b>."), context=context)
|
||||
|
||||
def done_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Procurement <b>done</b>."), context=context)
|
||||
|
||||
procurement_order()
|
||||
|
||||
class StockPicking(osv.osv):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def test_finished(self, cursor, user, ids):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
res = super(StockPicking, self).test_finished(cursor, user, ids)
|
||||
|
@ -494,8 +467,6 @@ class StockPicking(osv.osv):
|
|||
procurement.id, 'button_check', cursor)
|
||||
return res
|
||||
|
||||
StockPicking()
|
||||
|
||||
class stock_warehouse_orderpoint(osv.osv):
|
||||
"""
|
||||
Defines Minimum stock rules.
|
||||
|
|
|
@ -580,15 +580,6 @@ class product_product(osv.osv):
|
|||
'seller_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."),
|
||||
'seller_id': fields.function(_calc_seller, type='many2one', relation="res.partner", string='Main Supplier', help="Main Supplier who has highest priority in Supplier List.", multi="seller_info"),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(product_product, self).create(cr, uid, vals, context=context)
|
||||
self.create_send_note(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
return self.message_post(cr, uid, ids, body=_("Product has been <b>created</b>."), context=context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
unlink_ids = []
|
||||
unlink_product_tmpl_ids = []
|
||||
|
|
|
@ -354,7 +354,8 @@ class project_issue(base_stage, osv.osv):
|
|||
'task_id': new_task_id,
|
||||
'stage_id': self.stage_find(cr, uid, [bug], bug.project_id.id, [('state', '=', 'pending')], context=context),
|
||||
}
|
||||
self.convert_to_task_send_note(cr, uid, [bug.id], context=context)
|
||||
message = _("Project issue <b>converted</b> to task.")
|
||||
self.message_post(cr, uid, [bug.id], body=message, context=context)
|
||||
case_obj.write(cr, uid, [bug.id], vals, context=context)
|
||||
|
||||
return {
|
||||
|
@ -522,15 +523,6 @@ class project_issue(base_stage, osv.osv):
|
|||
|
||||
return super(project_issue, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
|
||||
|
||||
# -------------------------------------------------------
|
||||
# OpenChatter methods and notifications
|
||||
# -------------------------------------------------------
|
||||
|
||||
def convert_to_task_send_note(self, cr, uid, ids, context=None):
|
||||
message = _("Project issue <b>converted</b> to task.")
|
||||
return self.message_post(cr, uid, ids, body=message, context=context)
|
||||
|
||||
project_issue()
|
||||
|
||||
class project(osv.osv):
|
||||
_inherit = "project.project"
|
||||
|
|
|
@ -159,7 +159,12 @@ class purchase_order(osv.osv):
|
|||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')
|
||||
]
|
||||
|
||||
_track = {
|
||||
'state': {
|
||||
'purchase.mt_rfq_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state=='confirmed',
|
||||
'purchase.mt_rfq_approved': lambda self, cr, uid, obj, ctx=None: obj.state=='approved',
|
||||
},
|
||||
}
|
||||
_columns = {
|
||||
'name': fields.char('Order Reference', size=64, required=True, select=True, help="Unique number of the purchase order, computed automatically when the purchase order is created."),
|
||||
'origin': fields.char('Source Document', size=64,
|
||||
|
@ -169,7 +174,8 @@ class purchase_order(osv.osv):
|
|||
help="Reference of the sale order or quotation sent by your supplier. It's mainly used to do the matching when you receive the products as this reference is usually written on the delivery order sent by your supplier."),
|
||||
'date_order':fields.date('Order Date', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}, select=True, help="Date on which this document has been created."),
|
||||
'date_approve':fields.date('Date Approved', readonly=1, select=True, help="Date on which purchase order has been approved"),
|
||||
'partner_id':fields.many2one('res.partner', 'Supplier', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, change_default=True),
|
||||
'partner_id':fields.many2one('res.partner', 'Supplier', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]},
|
||||
change_default=True, track_visibility=2),
|
||||
'dest_address_id':fields.many2one('res.partner', 'Customer Address (Direct Delivery)',
|
||||
states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]},
|
||||
help="Put an address if you want to deliver directly from the supplier to the customer. " \
|
||||
|
@ -203,7 +209,7 @@ class purchase_order(osv.osv):
|
|||
'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Untaxed Amount',
|
||||
store={
|
||||
'purchase.order.line': (_get_order, None, 10),
|
||||
}, multi="sums", help="The amount without tax"),
|
||||
}, multi="sums", help="The amount without tax", track_visibility=2),
|
||||
'amount_tax': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Taxes',
|
||||
store={
|
||||
'purchase.order.line': (_get_order, None, 10),
|
||||
|
@ -242,8 +248,6 @@ class purchase_order(osv.osv):
|
|||
if vals.get('name','/')=='/':
|
||||
vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'purchase.order') or '/'
|
||||
order = super(purchase_order, self).create(cr, uid, vals, context=context)
|
||||
if order:
|
||||
self.create_send_note(cr, uid, [order], context=context)
|
||||
return order
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
@ -457,7 +461,6 @@ class purchase_order(osv.osv):
|
|||
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
|
||||
for id in ids:
|
||||
self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
|
||||
self.confirm_send_note(cr, uid, ids, context)
|
||||
return True
|
||||
|
||||
def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None):
|
||||
|
@ -488,7 +491,6 @@ class purchase_order(osv.osv):
|
|||
# Deleting the existing instance of workflow for PO
|
||||
wf_service.trg_delete(uid, 'purchase.order', p_id, cr)
|
||||
wf_service.trg_create(uid, 'purchase.order', p_id, cr)
|
||||
self.draft_send_note(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def action_invoice_create(self, cr, uid, ids, context=None):
|
||||
|
@ -555,13 +557,10 @@ class purchase_order(osv.osv):
|
|||
# Link this new invoice to related purchase order
|
||||
order.write({'invoice_ids': [(4, inv_id)]}, context=context)
|
||||
res = inv_id
|
||||
if res:
|
||||
self.invoice_send_note(cr, uid, ids, res, context)
|
||||
return res
|
||||
|
||||
def invoice_done(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state':'approved'}, context=context)
|
||||
self.invoice_done_send_note(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def has_stockable_product(self, cr, uid, ids, *args):
|
||||
|
@ -592,7 +591,6 @@ class purchase_order(osv.osv):
|
|||
|
||||
for (id, name) in self.name_get(cr, uid, ids):
|
||||
wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr)
|
||||
self.cancel_send_note(cr, uid, ids, context)
|
||||
return True
|
||||
|
||||
def _prepare_order_picking(self, cr, uid, order, context=None):
|
||||
|
@ -677,13 +675,10 @@ class purchase_order(osv.osv):
|
|||
# In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the
|
||||
# one that should trigger the advancement of the purchase workflow.
|
||||
# By default we will consider the first one as most important, but this behavior can be overridden.
|
||||
if picking_ids:
|
||||
self.shipment_send_note(cr, uid, ids, picking_ids[0], context=context)
|
||||
return picking_ids[0] if picking_ids else False
|
||||
|
||||
def picking_done(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'shipped':1,'state':'approved'}, context=context)
|
||||
self.shipment_done_send_note(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
@ -817,41 +812,6 @@ class purchase_order(osv.osv):
|
|||
def needaction_domain_get(self, cr, uid, ids, context=None):
|
||||
return [('state', '=', 'draft')]
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
return self.message_post(cr, uid, ids, body=_("Request for quotation <b>created</b>."), context=context)
|
||||
|
||||
def confirm_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to a Purchase Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), subtype="purchase.mt_rfq_confirmed", context=context)
|
||||
|
||||
def shipment_send_note(self, cr, uid, ids, picking_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# convert it to the user TZ and re-render it with %Z to add the timezone
|
||||
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
|
||||
self.message_post(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
|
||||
|
||||
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id):
|
||||
self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
|
||||
|
||||
def shipment_done_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("""Shipment <b>received</b>."""), context=context)
|
||||
|
||||
def invoice_done_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
|
||||
|
||||
def draft_send_note(self, cr, uid, ids, context=None):
|
||||
return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to <b>draft</b>."), context=context)
|
||||
|
||||
def cancel_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("Purchase Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
|
||||
|
||||
purchase_order()
|
||||
|
||||
class purchase_order_line(osv.osv):
|
||||
def _amount_line(self, cr, uid, ids, prop, arg, context=None):
|
||||
|
|
|
@ -49,10 +49,10 @@ class sale_order(osv.osv):
|
|||
_name = "sale.order"
|
||||
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
||||
_description = "Sales Order"
|
||||
|
||||
_track = {
|
||||
'state': {
|
||||
'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state in ['manual', 'progress']
|
||||
'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state in ['manual', 'progress'],
|
||||
'sale.mt_quotation_sent': lambda self, cr, uid, obj, ctx=None: obj.state in ['sent']
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -198,8 +198,8 @@ class sale_order(osv.osv):
|
|||
'date_order': fields.date('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
|
||||
'create_date': fields.datetime('Creation Date', readonly=True, select=True, help="Date on which sales order is created."),
|
||||
'date_confirm': fields.date('Confirmation Date', readonly=True, select=True, help="Date on which sales order is confirmed."),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, required=True, change_default=True, select=True),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True, track_visibility=1),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, required=True, change_default=True, select=True, track_visibility=2),
|
||||
'partner_invoice_id': fields.many2one('res.partner', 'Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Invoice address for current sales order."),
|
||||
'partner_shipping_id': fields.many2one('res.partner', 'Delivery Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Delivery address for current sales order."),
|
||||
'order_policy': fields.selection([
|
||||
|
@ -225,7 +225,7 @@ class sale_order(osv.osv):
|
|||
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
|
||||
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
|
||||
},
|
||||
multi='sums', help="The amount without tax."),
|
||||
multi='sums', help="The amount without tax.", track_visibility=2),
|
||||
'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Taxes',
|
||||
store={
|
||||
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
|
||||
|
@ -237,7 +237,7 @@ class sale_order(osv.osv):
|
|||
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
|
||||
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
|
||||
},
|
||||
multi='sums', track_visibility=2, help="The total amount."),
|
||||
multi='sums', help="The total amount."),
|
||||
|
||||
'invoice_quantity': fields.selection([('order', 'Ordered Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice).", required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
|
||||
|
@ -531,8 +531,6 @@ class sale_order(osv.osv):
|
|||
invoice_ids.append(res)
|
||||
self.write(cr, uid, [order.id], {'state': 'progress'})
|
||||
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (order.id, res))
|
||||
if res:
|
||||
self.invoice_send_note(cr, uid, ids, res, context)
|
||||
return res
|
||||
|
||||
def action_invoice_cancel(self, cr, uid, ids, context=None):
|
||||
|
@ -546,7 +544,6 @@ class sale_order(osv.osv):
|
|||
line.write({'state': 'confirmed'})
|
||||
if this.state == 'invoice_except':
|
||||
this.write({'state': 'progress'})
|
||||
this.invoice_paid_send_note()
|
||||
return True
|
||||
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
|
@ -645,15 +642,6 @@ class sale_order(osv.osv):
|
|||
def needaction_domain_get(self, cr, uid, ids, context=None):
|
||||
return [('state', '=', 'draft'), ('user_id', '=', uid)]
|
||||
|
||||
def invoice_paid_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
|
||||
|
||||
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id):
|
||||
self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
|
||||
|
||||
sale_order()
|
||||
|
||||
# TODO add a field price_unit_uos
|
||||
# - update it on change product and unit price
|
||||
|
|
|
@ -399,9 +399,6 @@ class sale_order(osv.osv):
|
|||
wf_service = netsvc.LocalService("workflow")
|
||||
if picking_id:
|
||||
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
|
||||
self.delivery_send_note(cr, uid, [order.id], picking_id, context)
|
||||
|
||||
|
||||
for proc_id in proc_ids:
|
||||
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
|
||||
|
||||
|
@ -440,8 +437,6 @@ class sale_order(osv.osv):
|
|||
if towrite:
|
||||
self.pool.get('sale.order.line').write(cr, uid, towrite, {'state': 'done'}, context=context)
|
||||
res = self.write(cr, uid, [order.id], val)
|
||||
if res:
|
||||
self.delivery_end_send_note(cr, uid, [order.id], context=context)
|
||||
return True
|
||||
|
||||
def has_stockable_products(self, cr, uid, ids, *args):
|
||||
|
@ -454,23 +449,11 @@ class sale_order(osv.osv):
|
|||
# ------------------------------------------------
|
||||
# OpenChatter methods and notifications
|
||||
# ------------------------------------------------
|
||||
|
||||
|
||||
def get_needaction_user_ids(self, cr, uid, ids, context=None):
|
||||
result = super(sale_order, self).get_needaction_user_ids(cr, uid, ids, context=context)
|
||||
return result
|
||||
|
||||
def delivery_send_note(self, cr, uid, ids, picking_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# convert it to the user TZ and re-render it with %Z to add the timezone
|
||||
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
|
||||
self.message_post(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
|
||||
|
||||
def delivery_end_send_note(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, ids, body=_("Order <b>delivered</b>."), context=context)
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
|
||||
def _number_packages(self, cr, uid, ids, field_name, arg, context=None):
|
||||
|
|
|
@ -621,8 +621,6 @@ class stock_picking(osv.osv):
|
|||
seq_obj_name = self._name
|
||||
vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)
|
||||
new_id = super(stock_picking, self).create(cr, user, vals, context)
|
||||
if new_id:
|
||||
self.create_send_note(cr, user, [new_id], context=context)
|
||||
return new_id
|
||||
|
||||
_columns = {
|
||||
|
@ -644,7 +642,7 @@ class stock_picking(osv.osv):
|
|||
('confirmed', 'Waiting Availability'),
|
||||
('assigned', 'Ready to Transfer'),
|
||||
('done', 'Transferred'),
|
||||
], 'Status', readonly=True, select=True, help="""
|
||||
], 'Status', readonly=True, select=True, track_visibility=1, help="""
|
||||
* Draft: not confirmed yet and will not be scheduled until confirmed\n
|
||||
* Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n
|
||||
* Waiting Availability: still waiting for the availability of products\n
|
||||
|
@ -666,7 +664,7 @@ class stock_picking(osv.osv):
|
|||
("invoiced", "Invoiced"),
|
||||
("2binvoiced", "To Be Invoiced"),
|
||||
("none", "Not Applicable")], "Invoice Control",
|
||||
select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
select=True, required=True, readonly=True, track_visibility=1, states={'draft': [('readonly', False)]}),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True, select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
|
||||
}
|
||||
_defaults = {
|
||||
|
@ -742,9 +740,6 @@ class stock_picking(osv.osv):
|
|||
@return: True
|
||||
"""
|
||||
pickings = self.browse(cr, uid, ids, context=context)
|
||||
for picking in pickings:
|
||||
if picking.state <> 'confirmed':
|
||||
self.confirm_send_note(cr, uid, [picking.id], context=context)
|
||||
self.write(cr, uid, ids, {'state': 'confirmed'})
|
||||
todo = []
|
||||
for picking in pickings:
|
||||
|
@ -869,7 +864,6 @@ class stock_picking(osv.osv):
|
|||
ids2 = [move.id for move in pick.move_lines]
|
||||
self.pool.get('stock.move').action_cancel(cr, uid, ids2, context)
|
||||
self.write(cr, uid, ids, {'state': 'cancel', 'invoice_state': 'none'})
|
||||
self.ship_cancel_send_note(cr, uid, ids, context)
|
||||
return True
|
||||
|
||||
#
|
||||
|
@ -1366,7 +1360,6 @@ class stock_picking(osv.osv):
|
|||
self.action_move(cr, uid, [pick.id], context=context)
|
||||
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr)
|
||||
delivered_pack_id = pick.id
|
||||
self.ship_done_send_note(cr, uid, ids, context)
|
||||
|
||||
delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
|
||||
res[pick.id] = {'delivered_picking': delivered_pack.id or False}
|
||||
|
@ -1442,35 +1435,12 @@ class stock_picking(osv.osv):
|
|||
}
|
||||
return type_dict.get(obj.type, _('Picking'))
|
||||
|
||||
def create_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("%s has been <b>created</b>.") % (self._get_document_type(cr, uid, obj, context=context)), context=context)
|
||||
|
||||
def confirm_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("%s has been <b>confirmed</b>.") % (self._get_document_type(cr, uid, obj, context=context)), context=context)
|
||||
|
||||
def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None):
|
||||
return self.message_post(cr, uid, ids, body= _("%s %s %s has been <b>moved to</b> scrap.") % (quantity, uom, name), context=context)
|
||||
|
||||
def back_order_send_note(self, cr, uid, ids, back_name, context=None):
|
||||
return self.message_post(cr, uid, ids, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_name), context=context)
|
||||
|
||||
def ship_done_send_note(self, cr, uid, ids, context=None):
|
||||
type_dict = {
|
||||
'out': _("Products have been <b>delivered</b>."),
|
||||
'in': _("Products have been <b>received</b>."),
|
||||
'internal': _("Products have been <b>moved</b>."),
|
||||
}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("Products have been <b>%s</b>.") % (type_dict.get(obj.type, 'move done')), context=context)
|
||||
|
||||
def ship_cancel_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id], body=_("%s has been <b>cancelled</b>.") % (self._get_document_type(cr, uid, obj, context=context)), context=context)
|
||||
|
||||
|
||||
stock_picking()
|
||||
|
||||
class stock_production_lot(osv.osv):
|
||||
|
||||
|
|
|
@ -103,18 +103,6 @@ class stock_change_product_qty(osv.osv_memory):
|
|||
|
||||
inventry_obj.action_confirm(cr, uid, [inventory_id], context=context)
|
||||
inventry_obj.action_done(cr, uid, [inventory_id], context=context)
|
||||
self.change_product_qty_send_note(cr, uid, [data.id], context)
|
||||
return {}
|
||||
|
||||
def change_product_qty_send_note(self, cr, uid, ids, context=None):
|
||||
prod_obj = self.pool.get('product.product')
|
||||
location_obj = self.pool.get('stock.location')
|
||||
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
location_name = location_obj.browse(cr, uid, data.location_id.id, context=context).name
|
||||
message = _("<b>Quantity has been changed</b> to <em>%s %s </em> for <em>%s</em> location.") % (data.new_quantity, data.product_id.uom_id.name, location_name)
|
||||
prod_obj.message_post(cr, uid, [data.product_id.id], body=message, context=context)
|
||||
|
||||
stock_change_product_qty()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue