prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [12.0] stock_secondary_unit "secondary qty" value in picking not affecting "initial demand"
  AFFECTED VERSIONS
  
  12.0 (it works ok on 13.0)
  
  STEPS TO REPRODUCE
  
  Activate Units of Measure in general settings > inventory
  
  Inventory > Master Data > Products > Set a secondary unit in a product
  
  ![image](https://user-images.githubusercontent.com/55489873/123983258-04aa0200-d9c4-11eb-90a1-e32686f07ac4.png)
  
  Create a new transfer > add product > select secondary UoM > input secondary qty
  
  ![image](https://user-images.githubusercontent.com/55489873/123983462-2e632900-d9c4-11eb-9b3c-c813bd2be121.png)
  
  CURRENT BEHAVIOR
  
  Value "Initial demand" is not affected by secondary qty input
  In the same way, if "Initial demand" is set, "secondary qty" does not change - basically there is no relation between the two fields
  
  ![image](https://user-images.githubusercontent.com/55489873/123983876-7f731d00-d9c4-11eb-9686-bf8d54618d2b.png)
  
  REQUIRED BEHAVIOR 
  
  When "secondary qty" is updated, also "initial demand" should update - and viceversa, as it happens in SO with secondary unit modules
  
  VIDEO
  
  https://recordit.co/zcuDUx6xco
  
  
  
  
  
  
  
  </issue>
  <code>
  [start of stock_secondary_unit/models/stock_move.py]
  1 # Copyright 2018 Tecnativa - Sergio Teruel
  2 # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3 from odoo import api, fields, models
  4 from odoo.addons import decimal_precision as dp
  5 from odoo.tools.float_utils import float_round
  6 
  7 
  8 class StockSecondaryUnitMixin(models.AbstractModel):
  9     _name = 'stock.secondary.unit.mixin'
  10     _description = 'Stock Secondary Unit Mixin'
  11 
  12     secondary_uom_id = fields.Many2one(
  13         comodel_name='product.secondary.unit',
  14         string='Second unit',
  15     )
  16     secondary_uom_qty = fields.Float(
  17         string='Secondary Qty',
  18         digits=dp.get_precision('Product Unit of Measure'),
  19     )
  20 
  21 
  22 class StockMove(models.Model):
  23     _inherit = ['stock.move', 'stock.secondary.unit.mixin']
  24     _name = 'stock.move'
  25 
  26     def _merge_moves_fields(self):
  27         res = super(StockMove, self)._merge_moves_fields()
  28         res['secondary_uom_qty'] = self[-1:].secondary_uom_qty
  29         return res
  30 
  31 
  32 class StockMoveLine(models.Model):
  33     _inherit = ['stock.move.line', 'stock.secondary.unit.mixin']
  34     _name = 'stock.move.line'
  35 
  36     @api.model
  37     def create(self, vals):
  38         move = self.env['stock.move'].browse(vals.get('move_id', False))
  39         if move.secondary_uom_id:
  40             uom = self.env['uom.uom'].browse(vals['product_uom_id'])
  41             factor = move.secondary_uom_id.factor * uom.factor
  42             move_line_qty = vals.get(
  43                 'product_uom_qty', vals.get('qty_done', 0.0))
  44             qty = float_round(
  45                 move_line_qty / (factor or 1.0),
  46                 precision_rounding=move.secondary_uom_id.uom_id.rounding
  47             )
  48             vals.update({
  49                 'secondary_uom_qty': qty,
  50                 'secondary_uom_id': move.secondary_uom_id.id,
  51             })
  52         return super().create(vals)
  53
  [end of stock_secondary_unit/models/stock_move.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/stock_secondary_unit/models/stock_move.py b/stock_secondary_unit/models/stock_move.py
  --- a/stock_secondary_unit/models/stock_move.py
  +++ b/stock_secondary_unit/models/stock_move.py
  @@ -2,7 +2,7 @@
   # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
   from odoo import api, fields, models
   from odoo.addons import decimal_precision as dp
  -from odoo.tools.float_utils import float_round
  +from odoo.tools.float_utils import float_compare, float_round
   
   
   class StockSecondaryUnitMixin(models.AbstractModel):
  @@ -28,6 +28,52 @@
           res['secondary_uom_qty'] = self[-1:].secondary_uom_qty
           return res
   
  +    @api.onchange('secondary_uom_id', 'secondary_uom_qty')
  +    def onchange_secondary_uom(self):
  +        if not self.secondary_uom_id:
  +            return
  +        factor = self.secondary_uom_id.factor * self.product_uom.factor
  +
  +        qty = float_round(
  +            self.secondary_uom_qty * factor,
  +            precision_rounding=self.product_uom.rounding
  +        )
  +        if float_compare(
  +            self.product_uom_qty, qty, precision_rounding=self.product_uom.rounding
  +        ) != 0:
  +            self.product_uom_qty = qty
  +
  +    @api.onchange('product_uom_qty')
  +    def onchange_secondary_unit_product_uom_qty(self):
  +        if not self.secondary_uom_id:
  +            return
  +        factor = self.secondary_uom_id.factor * self.product_uom.factor
  +
  +        qty = float_round(
  +            self.product_uom_qty / (factor or 1.0),
  +            precision_rounding=self.secondary_uom_id.uom_id.rounding
  +        )
  +        if float_compare(
  +            self.secondary_uom_qty,
  +            qty,
  +            precision_rounding=self.secondary_uom_id.uom_id.rounding
  +        ) != 0:
  +            self.secondary_uom_qty = qty
  +
  +    @api.onchange('product_uom')
  +    def onchange_product_uom_for_secondary(self):
  +        if not self.secondary_uom_id:
  +            return
  +        factor = self.product_uom.factor * self.secondary_uom_id.factor
  +        qty = float_round(
  +            self.product_uom_qty / (factor or 1.0),
  +            precision_rounding=self.product_uom.rounding
  +        )
  +        if float_compare(
  +            self.secondary_uom_qty, qty, precision_rounding=self.product_uom.rounding
  +        ) != 0:
  +            self.secondary_uom_qty = qty
  +
   
   class StockMoveLine(models.Model):
       _inherit = ['stock.move.line', 'stock.secondary.unit.mixin']
  
verification_info: {"golden_diff": "diff --git a/stock_secondary_unit/models/stock_move.py b/stock_secondary_unit/models/stock_move.py\n--- a/stock_secondary_unit/models/stock_move.py\n+++ b/stock_secondary_unit/models/stock_move.py\n@@ -2,7 +2,7 @@\n # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).\n from odoo import api, fields, models\n from odoo.addons import decimal_precision as dp\n-from odoo.tools.float_utils import float_round\n+from odoo.tools.float_utils import float_compare, float_round\n \n \n class StockSecondaryUnitMixin(models.AbstractModel):\n@@ -28,6 +28,52 @@\n         res['secondary_uom_qty'] = self[-1:].secondary_uom_qty\n         return res\n \n+    @api.onchange('secondary_uom_id', 'secondary_uom_qty')\n+    def onchange_secondary_uom(self):\n+        if not self.secondary_uom_id:\n+            return\n+        factor = self.secondary_uom_id.factor * self.product_uom.factor\n+\n+        qty = float_round(\n+            self.secondary_uom_qty * factor,\n+            precision_rounding=self.product_uom.rounding\n+        )\n+        if float_compare(\n+            self.product_uom_qty, qty, precision_rounding=self.product_uom.rounding\n+        ) != 0:\n+            self.product_uom_qty = qty\n+\n+    @api.onchange('product_uom_qty')\n+    def onchange_secondary_unit_product_uom_qty(self):\n+        if not self.secondary_uom_id:\n+            return\n+        factor = self.secondary_uom_id.factor * self.product_uom.factor\n+\n+        qty = float_round(\n+            self.product_uom_qty / (factor or 1.0),\n+            precision_rounding=self.secondary_uom_id.uom_id.rounding\n+        )\n+        if float_compare(\n+            self.secondary_uom_qty,\n+            qty,\n+            precision_rounding=self.secondary_uom_id.uom_id.rounding\n+        ) != 0:\n+            self.secondary_uom_qty = qty\n+\n+    @api.onchange('product_uom')\n+    def onchange_product_uom_for_secondary(self):\n+        if not self.secondary_uom_id:\n+            return\n+        factor = self.product_uom.factor * self.secondary_uom_id.factor\n+        qty = float_round(\n+            self.product_uom_qty / (factor or 1.0),\n+            precision_rounding=self.product_uom.rounding\n+        )\n+        if float_compare(\n+            self.secondary_uom_qty, qty, precision_rounding=self.product_uom.rounding\n+        ) != 0:\n+            self.secondary_uom_qty = qty\n+\n \n class StockMoveLine(models.Model):\n     _inherit = ['stock.move.line', 'stock.secondary.unit.mixin']\n", "issue": "[12.0] stock_secondary_unit \"secondary qty\" value in picking not affecting \"initial demand\"\nAFFECTED VERSIONS\r\n\r\n12.0 (it works ok on 13.0)\r\n\r\nSTEPS TO REPRODUCE\r\n\r\nActivate Units of Measure in general settings > inventory\r\n\r\nInventory > Master Data > Products > Set a secondary unit in a product\r\n\r\n![image](https://user-images.githubusercontent.com/55489873/123983258-04aa0200-d9c4-11eb-90a1-e32686f07ac4.png)\r\n\r\nCreate a new transfer > add product > select secondary UoM > input secondary qty\r\n\r\n![image](https://user-images.githubusercontent.com/55489873/123983462-2e632900-d9c4-11eb-9b3c-c813bd2be121.png)\r\n\r\nCURRENT BEHAVIOR\r\n\r\nValue \"Initial demand\" is not affected by secondary qty input\r\nIn the same way, if \"Initial demand\" is set, \"secondary qty\" does not change - basically there is no relation between the two fields\r\n\r\n![image](https://user-images.githubusercontent.com/55489873/123983876-7f731d00-d9c4-11eb-9686-bf8d54618d2b.png)\r\n\r\nREQUIRED BEHAVIOR \r\n\r\nWhen \"secondary qty\" is updated, also \"initial demand\" should update - and viceversa, as it happens in SO with secondary unit modules\r\n\r\nVIDEO\r\n\r\nhttps://recordit.co/zcuDUx6xco\r\n\r\n\r\n\r\n\r\n\r\n\n", "before_files": [{"content": "# Copyright 2018 Tecnativa - Sergio Teruel\n# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).\nfrom odoo import api, fields, models\nfrom odoo.addons import decimal_precision as dp\nfrom odoo.tools.float_utils import float_round\n\n\nclass StockSecondaryUnitMixin(models.AbstractModel):\n    _name = 'stock.secondary.unit.mixin'\n    _description = 'Stock Secondary Unit Mixin'\n\n    secondary_uom_id = fields.Many2one(\n        comodel_name='product.secondary.unit',\n        string='Second unit',\n    )\n    secondary_uom_qty = fields.Float(\n        string='Secondary Qty',\n        digits=dp.get_precision('Product Unit of Measure'),\n    )\n\n\nclass StockMove(models.Model):\n    _inherit = ['stock.move', 'stock.secondary.unit.mixin']\n    _name = 'stock.move'\n\n    def _merge_moves_fields(self):\n        res = super(StockMove, self)._merge_moves_fields()\n        res['secondary_uom_qty'] = self[-1:].secondary_uom_qty\n        return res\n\n\nclass StockMoveLine(models.Model):\n    _inherit = ['stock.move.line', 'stock.secondary.unit.mixin']\n    _name = 'stock.move.line'\n\n    @api.model\n    def create(self, vals):\n        move = self.env['stock.move'].browse(vals.get('move_id', False))\n        if move.secondary_uom_id:\n            uom = self.env['uom.uom'].browse(vals['product_uom_id'])\n            factor = move.secondary_uom_id.factor * uom.factor\n            move_line_qty = vals.get(\n                'product_uom_qty', vals.get('qty_done', 0.0))\n            qty = float_round(\n                move_line_qty / (factor or 1.0),\n                precision_rounding=move.secondary_uom_id.uom_id.rounding\n            )\n            vals.update({\n                'secondary_uom_qty': qty,\n                'secondary_uom_id': move.secondary_uom_id.id,\n            })\n        return super().create(vals)\n", "path": "stock_secondary_unit/models/stock_move.py"}]}