[MERGE] Merge with lp:openobject-addons
authorBhumika (OpenERP) <sbh@tinyerp.com>
Tue, 20 Mar 2012 05:22:58 +0000 (10:52 +0530)
committerBhumika (OpenERP) <sbh@tinyerp.com>
Tue, 20 Mar 2012 05:22:58 +0000 (10:52 +0530)
bzr revid: sbh@tinyerp.com-20120320052258-4g8zcpd248do6tw9

1  2 
addons/account/test/test_edi_invoice.yml
addons/event/event.py
addons/hr/hr_view.xml
addons/point_of_sale/point_of_sale_demo.xml
addons/purchase/test/process/edi_purchase_order.yml
addons/sale/sale_demo.xml
addons/sale/test/edi_sale_order.yml

          "partner_address": {
                  "__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",
                  "__module": "base",
 -                "__model": "res.partner.address",
 -                "phone": "(+32).81.81.37.00",
 -                "street": "Chaussee de Namur 40",
 -                "city": "Gerompont",
 -                "zip": "1367",
 -                "country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
 +                "__model": "res.partner",
 +                "phone": "(+32).81.81.37.00", 
 +                "street": "Chaussee de Namur 40", 
 +                "city": "Gerompont", 
 +                "zip": "1367", 
 +                "country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"], 
          },
-         "date_invoice": time.strftime('%Y-%m-%d'), 
-         "name": "sample invoice", 
+         "date_invoice": time.strftime('%Y-%m-%d'),
+         "name": "sample invoice",
          "tax_line": [{
-                 "__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_tax-4g4EutbiEMVl", 
+                 "__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_tax-4g4EutbiEMVl",
                  "__module": "account",
-                 "__model": "account.invoice.tax", 
-                 "amount": 1000.0, 
-                 "manual": True, 
-                 "name": "sale tax", 
-         }], 
-         "type": "out_invoice", 
+                 "__model": "account.invoice.tax",
+                 "amount": 1000.0,
+                 "manual": True,
+                 "name": "sale tax",
+         }],
+         "type": "out_invoice",
          "invoice_line": [{
                  "__module": "account",
                  "__model": "account.invoice.line",
@@@ -283,159 -217,55 +217,52 @@@ class event_registration(osv.osv)
      """Event Registration"""
      _name= 'event.registration'
      _description = __doc__
-     _inherit = 'mail.thread'
-     def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
-         cur_obj = self.pool.get('res.currency')
-         res = {}
-         for line in self.browse(cr, uid, ids, context=context):
-             price = line.unit_price * line.nb_register
-             pricelist = line.event_id.pricelist_id or line.partner_invoice_id.property_product_pricelist
-             cur = pricelist and pricelist.currency_id or False
-             res[line.id] = cur and cur_obj.round(cr, uid, cur, price) or price
-         return res
+     _inherit = ['mail.thread','res.partner.address']
      _columns = {
          'id': fields.integer('ID'),
-         'name': fields.char('Summary', size=124,  readonly=True, states={'draft': [('readonly', False)]}),
-         'email_cc': fields.text('CC', size=252, readonly=False, states={'done': [('readonly', True)]}, 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"),
-         'nb_register': fields.integer('Quantity', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="Number of Registrations or Tickets"),
+         'origin': fields.char('Origin', size=124,readonly=True,help="Name of the sale order which create the registration"),
+         'nb_register': fields.integer('Number of Participants', required=True, readonly=True, states={'draft': [('readonly', False)]}),
          'event_id': fields.many2one('event.event', 'Event', required=True, readonly=True, states={'draft': [('readonly', False)]}),
          'partner_id': fields.many2one('res.partner', 'Partner', states={'done': [('readonly', True)]}),
-         "partner_invoice_id": fields.many2one('res.partner', 'Partner Invoiced', readonly=True, states={'draft': [('readonly', False)]}),
-         "contact_id": fields.many2one('res.partner.address', 'Partner Contact', readonly=False, states={'done': [('readonly', True)]}), #TODO: filter only the contacts that have a function into the selected partner_id
-         "unit_price": fields.float('Unit Price', required=True, digits_compute=dp.get_precision('Sale Price'), readonly=True, states={'draft': [('readonly', False)]}),
-         'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute=dp.get_precision('Sale Price'), store=True),
-         "badge_ids": fields.one2many('event.registration.badge', 'registration_id', 'Badges', readonly=False, states={'done': [('readonly', True)]}),
-         "event_product": fields.char("Invoice Name", size=128, readonly=True, states={'draft': [('readonly', False)]}),
-         "tobe_invoiced": fields.boolean("To be Invoiced", readonly=True, states={'draft': [('readonly', False)]}),
-         "invoice_id": fields.many2one("account.invoice", "Invoice", readonly=True),
-         'date_closed': fields.datetime('Closed', readonly=True),
-         'ref': fields.reference('Reference', selection=crm._links_get, size=128),
-         'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
-         'email_from': fields.char('Email', size=128, states={'done': [('readonly', True)]}, help="These people will receive email."),
-         'create_date': fields.datetime('Creation Date', readonly=True),
-         'write_date': fields.datetime('Write Date', readonly=True),
-         'description': fields.text('Description', states={'done': [('readonly', True)]}),
-         'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
+         'partner_address_id': fields.many2one('res.partner.address', 'Partner', states={'done': [('readonly', True)]}),
+         "contact_id": fields.many2one('res.partner.address', 'Partner Contact', readonly=False, states={'done': [('readonly', True)]}),
+         'create_date': fields.datetime('Creation Date' , readonly=True),
+         'date_closed': fields.datetime('Attended Date', readonly=True),
+         'date_open': fields.datetime('Registration Date', readonly=True),
+         'reply_to': fields.related('event_id','reply_to',string='Reply-to Email', type='char', size=128, readonly=True,),
          'log_ids': fields.one2many('mail.message', 'res_id', 'Logs', domain=[('email_from', '=', False),('model','=',_name)]),
-         'date_deadline': fields.related('event_id','date_end', type='datetime', string="End Date", readonly=True),
-         'date': fields.related('event_id', 'date_begin', type='datetime', string="Start Date", readonly=True),
+         'event_end_date': fields.related('event_id','date_end', type='datetime', string="Event End Date", readonly=True),
+         'event_begin_date': fields.related('event_id', 'date_begin', type='datetime', string="Event Start Date", readonly=True),
          'user_id': fields.many2one('res.users', 'Responsible', states={'done': [('readonly', True)]}),
-         'active': fields.boolean('Active'),
-         'section_id': fields.related('event_id', 'section_id', type='many2one', relation='crm.case.section', string='Sale Team', store=True, readonly=True),
          'company_id': fields.related('event_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True, states={'draft':[('readonly',False)]}),
-         'state': fields.selection([('open', 'Confirmed'),
-                                     ('draft', 'Unconfirmed'),
+         'state': fields.selection([('draft', 'Unconfirmed'),
+                                     ('open', 'Confirmed'),
                                      ('cancel', 'Cancelled'),
-                                     ('done', 'Done')], 'State', \
+                                     ('done', 'Attended')], 'State',
                                      size=16, readonly=True)
      }
      _defaults = {
          'nb_register': 1,
-         'tobe_invoiced':  True,
          'state': 'draft',
-         'active': 1,
          'user_id': lambda self, cr, uid, ctx: uid,
      }
 -    _order = 'name, create_date desc'
 -
  
-     def _make_invoice(self, cr, uid, reg, lines, context=None):
-         """ Create Invoice from Invoice lines
-         @param reg: Model of Event Registration
-         @param lines: Ids of Invoice lines
-         """
-         if context is None:
-             context = {}
-         inv_pool = self.pool.get('account.invoice')
-         val_invoice = inv_pool.onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False)
-         val_invoice['value'].update({'partner_id': reg.partner_invoice_id.id})
-         val_invoice['value'].update({
-                 'origin': reg.event_product,
-                 'reference': False,
-                 'invoice_line': [(6, 0, lines)],
-                 'comment': "",
-                 'date_invoice': context.get('date_inv', False)
-             })
-         inv_id = inv_pool.create(cr, uid, val_invoice['value'], context=context)
-         inv_pool.button_compute(cr, uid, [inv_id])
-         self.message_append(cr, uid, [reg], _('Invoiced'))
-         return inv_id
+     def do_draft(self, cr, uid, ids, context=None):
+         return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
  
-     def copy(self, cr, uid, id, default=None, context=None):
-         """ Copy record of Given id
-         @param id: Id of Registration record.
-         @param context: A standard dictionary for contextual values
-         """
-         if not default:
-             default = {}
-         default.update({
-             'invoice_id': False,
-         })
-         return super(event_registration, self).copy(cr, uid, id, default=default, context=context)
-     def action_invoice_create(self, cr, uid, ids, grouped=False, date_inv = False, context=None):
-         """ Action of Create Invoice """
-         res = False
-         invoices = {}
-         tax_ids=[]
-         new_invoice_ids = []
-         inv_lines_pool = self.pool.get('account.invoice.line')
-         inv_pool = self.pool.get('account.invoice')
-         product_pool = self.pool.get('product.product')
-         contact_pool = self.pool.get('res.partner.address')
-         if context is None:
-             context = {}
-         # If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the
-         # last day of the last month as invoice date
-         if date_inv:
-             context['date_inv'] = date_inv
-         for reg in self.browse(cr, uid, ids, context=context):
-             val_invoice = inv_pool.onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False)
-             val_invoice['value'].update({'partner_id': reg.partner_invoice_id.id})
-             if not partner_address_id:
-                raise osv.except_osv(_('Error !'),
-                         _("Registered partner doesn't have an address to make the invoice."))
-             value = inv_lines_pool.product_id_change(cr, uid, [], reg.event_id.product_id.id, uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id)
-             product = product_pool.browse(cr, uid, reg.event_id.product_id.id, context=context)
-             for tax in product.taxes_id:
-                 tax_ids.append(tax.id)
-             vals = value['value']
-             c_name = reg.contact_id and ('-' + contact_pool.name_get(cr, uid, [reg.contact_id.id])[0][1]) or ''
-             vals.update({
-                 'name': reg.event_product + '-' + c_name,
-                 'price_unit': reg.unit_price,
-                 'quantity': reg.nb_register,
-                 'product_id':reg.event_id.product_id.id,
-                 'invoice_line_tax_id': [(6, 0, tax_ids)],
-             })
-             inv_line_ids = self._create_invoice_lines(cr, uid, [reg.id], vals)
-             invoices.setdefault(reg.partner_id.id, []).append((reg, inv_line_ids))
-         for val in invoices.values():
-             res = False
-             if grouped:
-                 res = self._make_invoice(cr, uid, val[0][0], [v for k, v in val], context=context)
-                 for k, v in val:
-                     self.do_close(cr, uid, [k.id], context={'invoice_id': res})
+     def confirm_registration(self, cr, uid, ids, context=None):
+         self.message_append(cr, uid, ids,_('State set to open'),body_text= _('Open'))
+         return self.write(cr, uid, ids, {'state': 'open'}, context=context)
  
-             else:
-                for k, v in val:
-                    res = self._make_invoice(cr, uid, k, [v], context=context)
-                    self.do_close(cr, uid, [k.id], context={'invoice_id': res})
-             if res: new_invoice_ids.append(res)
-         return new_invoice_ids
-     def do_open(self, cr, uid, ids, context=None):
-         """ Open Registration
+     def registration_open(self, cr, uid, ids, context=None):
 -        """ Open Registration
          """
-         res = self.write(cr, uid, ids, {'state': 'open'}, context=context)
-         self.mail_user(cr, uid, ids)
-         self.message_append(cr, uid, ids, _('Open'))
+         res = self.confirm_registration(cr, uid, ids, context=context)
+         self.mail_user(cr, uid, ids, context=context)
          return res
  
-     def do_close(self, cr, uid, ids, context=None):
+     def button_reg_close(self, cr, uid, ids, context=None):
          """ Close Registration
          """
          if context is None:
Simple merge
Simple merge
                  "bank_ids": [
                      ["base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_bank-adaWadsadasdDJzGbp","Ladies bank: 032465789-156113"]
                  ],
 -        },
 -        "partner_id": ["purchase:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_test20", "jones white"],
 -        "partner_address": {
 -                "__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",
 -                "__module": "base",
 -                "__model": "res.partner.address",
 -                "phone": "(+32).81.81.37.00",
 -                "street": "Chaussee de Namur 40",
 -                "city": "Gerompont",
 -                "zip": "1367",
 -                "country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
 -        },
 +        }, 
 +        "partner_id": ["purchase:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_test20", "jones white"], 
-       
          "order_line": [{
-                 "__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-AlhsVDZGoKvJ", 
-                 "__module": "purchase", 
+                 "__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-AlhsVDZGoKvJ",
+                 "__module": "purchase",
                  "__model": "purchase.order.line",
-                 "__import_module": "sale", 
-                 "__import_model": "sale.order.line", 
-                 "name": "Basic PC", 
-                 "date_planned": "2011-09-30", 
-                 "price_unit": 150.0, 
+                 "__import_module": "sale",
+                 "__import_model": "sale.order.line",
+                 "name": "Basic PC",
+                 "date_planned": "2011-09-30",
+                 "price_unit": 150.0,
                  "product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_pc1", "[PC1] Basic PC"],
-                 "product_qty": 1.0, 
-                 "product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "PCE"], 
+                 "product_qty": 1.0,
+                 "product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "Unit"],
          },
          {
-                 "__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-Alsads33e", 
-                 "__module": "purchase", 
+                 "__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-Alsads33e",
+                 "__module": "purchase",
                  "__model": "purchase.order.line",
-                 "__import_module": "sale", 
+                 "__import_module": "sale",
                  "__import_model": "sale.order.line",
-                 "name": "Medium PC", 
-                 "date_planned": "2011-09-15", 
-                 "price_unit": 100.0, 
+                 "name": "Medium PC",
+                 "date_planned": "2011-09-15",
+                 "price_unit": 100.0,
                  "product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_pc3", "[PC3] Medium PC"],
-                 "product_qty": 2.0, 
-                 "product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "PCE"], 
-         }], 
+                 "product_qty": 2.0,
+                 "product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "Unit"],
+         }],
      }
      new_sale_order_id = sale_order_pool.edi_import(cr, uid, edi_document, context=context)
      assert new_sale_order_id,  'Sale order import failed'
              assert sale_line.price_unit == 100 , "unit price is not same, got %s, expected 100"%(sale_line.price_unit,)
              assert sale_line.product_uom_qty == 2 , "product qty is not same"
          else:
--            raise AssertionError('unknown order line: %s' % sale_line)
++            raise AssertionError('unknown order line: %s' % sale_line)