← Back to team overview

credativ team mailing list archive

[Merge] lp:~therp-nl/openupgrade-addons/7.0-account-payment_terms into lp:openupgrade-addons

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/7.0-account-payment_terms into lp:openupgrade-addons.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/7.0-account-payment_terms/+merge/181953
-- 
https://code.launchpad.net/~therp-nl/openupgrade-addons/7.0-account-payment_terms/+merge/181953
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/7.0-account-payment_terms into lp:openupgrade-addons.
=== modified file 'account/migrations/7.0.1.1/post-migration.py'
--- account/migrations/7.0.1.1/post-migration.py	2013-07-24 12:41:33 +0000
+++ account/migrations/7.0.1.1/post-migration.py	2013-08-24 11:52:23 +0000
@@ -75,12 +75,54 @@
             cr, SUPERUSER_ID, reconcile_ids,
             {'opening_reconciliation': True})
 
+def migrate_payment_term(cr, pool):
+    partner_obj = pool.get('res.partner')
+    field_id = pool.get('ir.model.fields').search(
+        cr, SUPERUSER_ID, [
+            ('name', '=', 'property_supplier_payment_term'),
+            ('model', '=', 'res.partner'),
+            ])[0]
+          
+    cr.execute(
+        """
+        SELECT company_id, value_reference, res_id
+        FROM ir_property
+        WHERE name = 'property_payment_term'
+        AND res_id like 'res.partner,%'
+        """)
+    for row in cr.fetchall():
+        if partner_obj.read(
+                cr, SUPERUSER_ID, int(row[2][12:]), ['supplier']
+                )['supplier']:
+            cr.execute(
+                """
+                INSERT INTO ir_property (
+                    create_uid,
+                    create_date,
+                    name,
+                    type,
+                    company_id,
+                    fields_id,
+                    value_reference,
+                    res_id)
+                VALUES(
+                    %s,
+                    CURRENT_TIMESTAMP AT TIME ZONE 'UTC',
+                    'property_supplier_payment_term',
+                    'many2one',
+                    %s,
+                    %s,
+                    %s,
+                    %s)
+                """, (SUPERUSER_ID, row[0], field_id, row[1], row[2]))
+        
 @openupgrade.migrate()
 def migrate(cr, version):
     pool = pooler.get_pool(cr.dbname)
     migrate_invoice_addresses(cr, pool)
     migrate_invoice_names(cr, pool)
     lock_closing_reconciliations(cr, pool)
+    migrate_payment_term(cr, pool)
     openupgrade.load_xml(
         cr, 'account',
         'migrations/7.0.1.1/data.xml')

=== modified file 'account/migrations/7.0.1.1/user_notes.txt'
--- account/migrations/7.0.1.1/user_notes.txt	2013-07-24 12:41:33 +0000
+++ account/migrations/7.0.1.1/user_notes.txt	2013-08-24 11:52:23 +0000
@@ -8,3 +8,5 @@
 This upgrade resets the contents of your invoice email template, because the old version contains non-existing fields. Because the translations, which contain the same, now invalid references are managed separately, you are encouraged to force an overwrite of the translations and redo any customization of the template.
 
 The label of invoice lines is now a multiline text field. Your existing labels and line notes are combined in this new field.
+
+Partners now have a separate payment term for purchases. Existing payment terms on suppliers will be duplicated into to this field.


Follow ups