Repository: juju/python-libjuju
Issue: [Bug]: `model.deploy` with `channel` and `series` parameters deploys different revision with respect to juju cli

### Description

When `model.deploy()` is used with `channel` and `series` parameters, it dpeloys a different revision of the charm with respect to using `juju` cli.
Using `juju` cli:
```
> juju deploy osm-lcm lcm --channel=latest/beta --resource lcm-image=opensourcemano/lcm:testing-daily --series focal
Located charm "osm-lcm" in charm-hub, revision 152
Deploying "lcm" from charm-hub charm "osm-lcm", revision 152 in channel latest/beta on focal
> juju status
App  Version  Status   Scale  Charm    Channel      Rev  Address        Exposed  Message
lcm           waiting      1  osm-lcm  latest/beta  152  10.152.183.22  no       installing agent
> juju show-application lcm
lcm:
  charm: osm-lcm
  series: focal
  channel: latest/beta
  constraints:
    arch: amd64
  principal: true
  exposed: false
  remote: false
  life: alive
  endpoint-bindings:
    "": alpha
    kafka: alpha
    mongodb: alpha
    ro: alpha
    vca: alpha
```
Using `libjuju`:
```
> await model.deploy("osm-lcm", application_name="lcm", channel="latest/beta", resources={"lcm-image": "opensourcemano/lcm:testing-daily"}, series="focal")
> juju status
App  Version  Status   Scale  Charm    Channel  Rev  Address         Exposed  Message
lcm           waiting      1  osm-lcm  beta      11  10.152.183.112  no       installing agent
> juju show-application lcm      
lcm:
  charm: osm-lcm
  series: focal
  channel: beta
  constraints:
    arch: amd64
  principal: true
  exposed: false
  remote: false
  life: alive
  endpoint-bindings:
    "": alpha
    kafka: alpha
    mongodb: alpha
    ro: alpha
    vca: alpha
```
This is the upstream:
```
> charmcraft status osm-lcm
Track    Base                    Channel                       Version    Revision    Resources       Expires at                                                                                           
latest   ubuntu 20.04 (aarch64)  stable                        113        113         image (r1)                                                                                                           
                                 candidate                     1          1           image (r1)                                                                                                           
                                 beta                          2          2           image (r1)                                                                                                           
                                 edge                          1          1           image (r1)                                                                                                           
         ubuntu 20.04 (amd64)    stable                        113        113         image (r1)                                                                                                           
                                 candidate                     1          1           image (r1)                                                                                                           
                                 beta                          152        152         lcm-image (r1)                                                                                                       
                                 edge                          1          1           image (r1)                                                                                                           
                                 edge/merged                   152        152         lcm-image (r1)  2023-04-02T00:00:00Z                                                                                 
                                 edge/paas                     154        154         lcm-image (r1)  2023-04-22T00:00:00Z                                                                                 
                                 edge/refs-changes-87-12987-2  148        148         lcm-image (r1)  2023-03-26T00:00:00Z                                                                                 
                                 edge/refs-changes-87-12987-3  150        150         lcm-image (r1)  2023-03-30T00:00:00Z                                                                                 
                                 edge/refs-changes-87-12987-4  151        151         lcm-image (r1)  2023-03-31T00:00:00Z                                                                                 
                                 edge/refs-changes-92-13092-1  155        155         lcm-image (r1)  2023-04-23T00:00:00Z                                                                                 
                                 edge/refs-changes-92-13092-2  156        156         lcm-image (r1)  2023-04-23T00:00:00Z                                                                                 
                                 edge/refs-changes-92-13092-3  157        157         lcm-image (r1)  2023-04-23T00:00:00Z                                                                                 
         ubuntu 20.04 (arm64)    stable                        113        113         image (r1)                                                                                                           
                                 candidate                     1          1           image (r1)                                                                                                           
                                 beta                          2          2           image (r1)                                                                                                           
                                 edge                          1          1           image (r1)                                                                                                           
         ubuntu 22.04 (amd64)    stable                        -          -           -                                                                                                                    
                                 candidate                     -          -           -                                                                                                                    
                                 beta                          11         11          lcm-image (r1)                                                                                                       
                                 edge                          ↑          ↑           ↑
```

### Urgency

Annoying bug in our test suite

### Python-libjuju version

2.9.42.1

### Juju version

2.9.42

### Reproduce / Test

```python
from juju import jasyncio
from juju.model import Model


LCM_CHARM = "osm-lcm"
LCM_APP = "lcm"
LCM_CHANNEL = "latest/beta"
LCM_SERIES = "focal"
LCM_RESOURCES = {"lcm-image": "opensourcemano/lcm:testing-daily"}

async def deploy():
    model = Model()
    await model.connect_current()
    try:
        await model.deploy(
            LCM_CHARM,
            application_name=LCM_APP,
            resources=LCM_RESOURCES,
            channel=LCM_CHANNEL,
            series=LCM_SERIES,
        )
    finally:
        await model.disconnect()

def main():
    jasyncio.run(deploy())

if __name__ == "__main__":
    main()
```


Changed files:
juju/model.py

diff --git a/juju/model.py b/juju/model.py
index fdd66cc..bef53f3 100644
--- a/juju/model.py
+++ b/juju/model.py
@@ -552,23 +552,14 @@ class CharmhubDeployType:
         origin = client.CharmOrigin(source="charm-hub",
                                     architecture=architecture,
                                     risk=ch.risk,
-                                    track=ch.track)
+                                    track=ch.track,
+                                    series=series)
 
-        charm_url_str, origin, supported_series = await self.charm_resolver(url, origin)
-        charm_url = URL.parse(charm_url_str)
+        charm_url, origin = await self.charm_resolver(url, origin, force)
 
         if app_name is None:
             app_name = url.name
 
-        if series:
-            # Check whether the charm supports this series
-            # or we force it
-            if series in supported_series or force:
-                origin.series = series
-                charm_url.series = series
-            else:
-                raise JujuError("Series {} not supported for {}. Only {}".format(series, url, supported_series))
-
         return DeployTypeResult(
             identifier=str(charm_url),
             app_name=app_name,
@@ -1722,7 +1713,7 @@ class Model:
         client_facade = client.ClientFacade.from_connection(self.connection())
         return await client_facade.AddCharm(channel=str(origin.risk), url=charm_url, force=False)
 
-    async def _resolve_charm(self, url, origin):
+    async def _resolve_charm(self, url, origin, force):
         charms_cls = client.CharmsFacade
         if charms_cls.best_facade_version(self.connection()) < 3:
             raise JujuError("resolve charm")
@@ -1733,9 +1724,11 @@ class Model:
             source = "charm-store"
         else:
             source = "charm-hub"
+
         resp = await charms_facade.ResolveCharms(resolve=[{
             'reference': str(url),
             'charm-origin': {
+                'series': origin.series,
                 'source': source,
                 'architecture': origin.architecture,
                 'track': origin.track,
@@ -1749,7 +1742,18 @@ class Model:
         if result.error:
             raise JujuError(result.error.message)
 
-        return (result.url, result.charm_origin, result.supported_series)
+        supported_series = result.supported_series
+        charm_url = URL.parse(result.url)
+        if origin.series:
+            # Check whether the charm supports this series
+            # or we force it
+            if origin.series in supported_series or force:
+                result.charm_origin.series = origin.series
+                charm_url.series = origin.series
+            else:
+                raise JujuError("Series {} not supported for {}. Only {}".format(origin.series, result.url, supported_series))
+
+        return charm_url, result.charm_origin
 
     async def _resolve_architecture(self, url):
         if url.architecture: